helper.c (ff7de2fc2c994030bfb83af9ddc9a3cd70ce3e88) | helper.c (ce3125bed935a12e619a8253c19340ecaa899347) |
---|---|
1/* 2 * ARM generic helpers. 3 * 4 * This code is licensed under the GNU GPL v2 or later. 5 * 6 * SPDX-License-Identifier: GPL-2.0-or-later 7 */ 8 --- 9894 unchanged lines hidden (view full) --- 9903{ 9904 return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); 9905} 9906 9907/* Translate S2 section/page access permissions to protection flags 9908 * 9909 * @env: CPUARMState 9910 * @s2ap: The 2-bit stage2 access permissions (S2AP) | 1/* 2 * ARM generic helpers. 3 * 4 * This code is licensed under the GNU GPL v2 or later. 5 * 6 * SPDX-License-Identifier: GPL-2.0-or-later 7 */ 8 --- 9894 unchanged lines hidden (view full) --- 9903{ 9904 return simple_ap_to_rw_prot_is_user(ap, regime_is_user(env, mmu_idx)); 9905} 9906 9907/* Translate S2 section/page access permissions to protection flags 9908 * 9909 * @env: CPUARMState 9910 * @s2ap: The 2-bit stage2 access permissions (S2AP) |
9911 * @xn: XN (execute-never) bit | 9911 * @xn: XN (execute-never) bits 9912 * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 |
9912 */ | 9913 */ |
9913static int get_S2prot(CPUARMState *env, int s2ap, int xn) | 9914static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) |
9914{ 9915 int prot = 0; 9916 9917 if (s2ap & 1) { 9918 prot |= PAGE_READ; 9919 } 9920 if (s2ap & 2) { 9921 prot |= PAGE_WRITE; 9922 } | 9915{ 9916 int prot = 0; 9917 9918 if (s2ap & 1) { 9919 prot |= PAGE_READ; 9920 } 9921 if (s2ap & 2) { 9922 prot |= PAGE_WRITE; 9923 } |
9923 if (!xn) { 9924 if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { | 9924 9925 if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { 9926 switch (xn) { 9927 case 0: |
9925 prot |= PAGE_EXEC; | 9928 prot |= PAGE_EXEC; |
9929 break; 9930 case 1: 9931 if (s1_is_el0) { 9932 prot |= PAGE_EXEC; 9933 } 9934 break; 9935 case 2: 9936 break; 9937 case 3: 9938 if (!s1_is_el0) { 9939 prot |= PAGE_EXEC; 9940 } 9941 break; 9942 default: 9943 g_assert_not_reached(); |
|
9926 } | 9944 } |
9945 } else { 9946 if (!extract32(xn, 1, 1)) { 9947 if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { 9948 prot |= PAGE_EXEC; 9949 } 9950 } |
|
9927 } 9928 return prot; 9929} 9930 9931/* Translate section/page access permissions to protection flags 9932 * 9933 * @env: CPUARMState 9934 * @mmu_idx: MMU index indicating required translation regime --- 961 unchanged lines hidden (view full) --- 10896 */ 10897 fault_type = ARMFault_AccessFlag; 10898 if ((attrs & (1 << 8)) == 0) { 10899 /* Access flag */ 10900 goto do_fault; 10901 } 10902 10903 ap = extract32(attrs, 4, 2); | 9951 } 9952 return prot; 9953} 9954 9955/* Translate section/page access permissions to protection flags 9956 * 9957 * @env: CPUARMState 9958 * @mmu_idx: MMU index indicating required translation regime --- 961 unchanged lines hidden (view full) --- 10920 */ 10921 fault_type = ARMFault_AccessFlag; 10922 if ((attrs & (1 << 8)) == 0) { 10923 /* Access flag */ 10924 goto do_fault; 10925 } 10926 10927 ap = extract32(attrs, 4, 2); |
10904 xn = extract32(attrs, 12, 1); | |
10905 10906 if (mmu_idx == ARMMMUIdx_Stage2) { 10907 ns = true; | 10928 10929 if (mmu_idx == ARMMMUIdx_Stage2) { 10930 ns = true; |
10908 *prot = get_S2prot(env, ap, xn); | 10931 xn = extract32(attrs, 11, 2); 10932 *prot = get_S2prot(env, ap, xn, s1_is_el0); |
10909 } else { 10910 ns = extract32(attrs, 3, 1); | 10933 } else { 10934 ns = extract32(attrs, 3, 1); |
10935 xn = extract32(attrs, 12, 1); |
|
10911 pxn = extract32(attrs, 11, 1); 10912 *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); 10913 } 10914 10915 fault_type = ARMFault_Permission; 10916 if (!(*prot & (1 << access_type))) { 10917 goto do_fault; 10918 } --- 1893 unchanged lines hidden --- | 10936 pxn = extract32(attrs, 11, 1); 10937 *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); 10938 } 10939 10940 fault_type = ARMFault_Permission; 10941 if (!(*prot & (1 << access_type))) { 10942 goto do_fault; 10943 } --- 1893 unchanged lines hidden --- |