On 03/12/2025 6:49 pm, Andrew Cooper wrote:
> On 03/12/2025 6:23 pm, Julien Grall wrote:
>> Hi Andrew,
>>
>> On 03/12/2025 17:16, Andrew Cooper wrote:
>>> to keep it working, but there was apparently no use of ThumbEE
>>> outside of demo
>>> code, so simply drop it.
>> I am in favor of dropping support for ThumbEE for guest. But I am not
>> sure I understand this comment.
> There's no production use of ThumbEE known to ARM.
>
>> Are you saying there are no processors supporting ThumbEE where Xen
>> would run? Asking because below, you are removing code to context
>> switch the ThumbEE registers. But I don't see any code that would
>> ensure the registers are trapping (i.e. HSTR.TEE is set). So wouldn't
>> this result to a cross-VM leak on those processors?
>>
>> If we really don't want to support CPU where ThumbEE is available,
>> then we should check that "cpu_has_thumbee" is 0.
> The registers exist in ARM v7 only.  They do not exist in ARM v8.
>
> I suppose yes this change would result in a cross-VM leak on hardware
> supporting ThumbEE.
>
> Can HSTR.TTEE be set unilaterally, or does it need gating on
> cpu_has_thumbee?
>
> Is setting HSTR.TTEE sufficient to cause an undefined instruction
> exception to be thrown back at a guest which goes poking?  (I guess this
> is really "will the default do the right thing")
>
> I'll freely admit that I'm out of my depth here, but the build failure
> does need fixing.

e.g.

diff --git a/xen/arch/arm/include/asm/processor.h 
b/xen/arch/arm/include/asm/processor.h
index 92c8bc1a3125..ec23fd098b63 100644
--- a/xen/arch/arm/include/asm/processor.h
+++ b/xen/arch/arm/include/asm/processor.h
@@ -411,6 +411,7 @@
 
 /* HSTR Hyp. System Trap Register */
 #define HSTR_T(x)       ((_AC(1,U)<<(x)))       /* Trap Cp15 c<x> */
+#define HSTR_TTEE       (_AC(1,U)<<16)          /* Trap ThumbEE */
 
 /* HDCR Hyp. Debug Configuration Register */
 #define HDCR_TDRA       (_AC(1,U)<<11)          /* Trap Debug ROM access */
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 2bc3e1df0416..040c0f2e0db1 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -158,8 +158,8 @@ void init_traps(void)
     WRITE_SYSREG(HDCR_TDRA|HDCR_TDOSA|HDCR_TDA|HDCR_TPM|HDCR_TPMCR,
                  MDCR_EL2);
 
-    /* Trap CP15 c15 used for implementation defined registers */
-    WRITE_SYSREG(HSTR_T(15), HSTR_EL2);
+    /* Trap CP15 c15 used for implementation defined registers, and ThumbEE. */
+    WRITE_SYSREG(HSTR_T(15) | (cpu_has_thumbee ? HSTR_TTEE : 0), HSTR_EL2);
 
     WRITE_SYSREG(get_default_cptr_flags(), CPTR_EL2);


Reply via email to