[PATCH for-4.22?] xen/arm: mask debug exceptions in initial AArch64 guest state

Mykola Kvach posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/74e132a5f3dff64be5bd0c04eb82fe78d9c2fe84.1781892316.git.mykola._5Fkvach@epam.com
xen/include/public/arch-arm.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH for-4.22?] xen/arm: mask debug exceptions in initial AArch64 guest state
Posted by Mykola Kvach 1 month ago
PSR_GUEST64_INIT currently masks SError, IRQ and FIQ, but leaves debug
exceptions unmasked. Both the AArch64 Linux boot protocol and PSCI entry
requirements expect PSTATE.DAIF to be masked.

Add PSR_DBG_MASK to PSR_GUEST64_INIT. This fixes the initial AArch64 guest
entry state as well as virtual PSCI CPU_ON and SYSTEM_SUSPEND resume entry.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
---
 xen/include/public/arch-arm.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 7d6f87e8b2..00de30b896 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -420,7 +420,8 @@ typedef uint64_t xen_callback_t;
  * zImage kernels on aarch32.
  */
 #define PSR_GUEST32_INIT (PSR_Z|PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_SVC)
-#define PSR_GUEST64_INIT (PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_EL1h)
+#define PSR_GUEST64_INIT \
+    (PSR_DBG_MASK|PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_EL1h)
 
 #define SCTLR_GUEST_INIT    xen_mk_ullong(0x00c50078)
 
-- 
2.43.0
Re: [PATCH for-4.22?] xen/arm: mask debug exceptions in initial AArch64 guest state
Posted by Julien Grall 1 month ago
Hi Mykola,

On 19/06/2026 19:37, Mykola Kvach wrote:
> PSR_GUEST64_INIT currently masks SError, IRQ and FIQ, but leaves debug
> exceptions unmasked. Both the AArch64 Linux boot protocol and PSCI entry
> requirements expect PSTATE.DAIF to be masked.
> 
> Add PSR_DBG_MASK to PSR_GUEST64_INIT. This fixes the initial AArch64 guest
> entry state as well as virtual PSCI CPU_ON and SYSTEM_SUSPEND resume entry.
> 
> Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>

Reviewed-by: Julien Grall <julien@xen.org>

Regarding Xen 4.22, I understand and agree this is technically against 
the specification. However, AFAIR, we don't expose debug registers to 
the guest. So there should be no impact.

The slight risk with this patch is OS that may have started to rely on 
Xen behavior (hopefully not here, but I know we had a couple of cases 
with the timer for instance...).

This has been present forever. So unless there is a real issue, I am 
tempted to suggest to wait until the release is out and backport after.

I will leave Oleksii the final decision.

Cheers,

-- 
Julien Grall
Re: [PATCH for-4.22?] xen/arm: mask debug exceptions in initial AArch64 guest state
Posted by Mykola Kvach 1 month ago
Hi Julien,

Thanks for the review.

On Sat, Jun 20, 2026 at 12:07 AM Julien Grall <julien@xen.org> wrote:
>
> Hi Mykola,
>
> On 19/06/2026 19:37, Mykola Kvach wrote:
> > PSR_GUEST64_INIT currently masks SError, IRQ and FIQ, but leaves debug
> > exceptions unmasked. Both the AArch64 Linux boot protocol and PSCI entry
> > requirements expect PSTATE.DAIF to be masked.
> >
> > Add PSR_DBG_MASK to PSR_GUEST64_INIT. This fixes the initial AArch64 guest
> > entry state as well as virtual PSCI CPU_ON and SYSTEM_SUSPEND resume entry.
> >
> > Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
>
> Reviewed-by: Julien Grall <julien@xen.org>
>
> Regarding Xen 4.22, I understand and agree this is technically against
> the specification. However, AFAIR, we don't expose debug registers to
> the guest. So there should be no impact.
>
> The slight risk with this patch is OS that may have started to rely on
> Xen behavior (hopefully not here, but I know we had a couple of cases
> with the timer for instance...).
>
> This has been present forever. So unless there is a real issue, I am
> tempted to suggest to wait until the release is out and backport after.
>
> I will leave Oleksii the final decision.

I agree with your assessment. I am fine with deferring this until after the
release unless Oleksii decides otherwise.

The patch is not fixing any known issue and was only intended to align the
guest entry state with the documented requirements.

Best regards,
Mykola
Re: [PATCH for-4.22?] xen/arm: mask debug exceptions in initial AArch64 guest state
Posted by Oleksii Kurochko 1 month ago
Hello Mykola and Julien,

On 6/21/26 4:30 PM, Mykola Kvach wrote:
> Hi Julien,
> 
> Thanks for the review.
> 
> On Sat, Jun 20, 2026 at 12:07 AM Julien Grall <julien@xen.org> wrote:
>>
>> Hi Mykola,
>>
>> On 19/06/2026 19:37, Mykola Kvach wrote:
>>> PSR_GUEST64_INIT currently masks SError, IRQ and FIQ, but leaves debug
>>> exceptions unmasked. Both the AArch64 Linux boot protocol and PSCI entry
>>> requirements expect PSTATE.DAIF to be masked.
>>>
>>> Add PSR_DBG_MASK to PSR_GUEST64_INIT. This fixes the initial AArch64 guest
>>> entry state as well as virtual PSCI CPU_ON and SYSTEM_SUSPEND resume entry.
>>>
>>> Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
>>
>> Reviewed-by: Julien Grall <julien@xen.org>
>>
>> Regarding Xen 4.22, I understand and agree this is technically against
>> the specification. However, AFAIR, we don't expose debug registers to
>> the guest. So there should be no impact.
>>
>> The slight risk with this patch is OS that may have started to rely on
>> Xen behavior (hopefully not here, but I know we had a couple of cases
>> with the timer for instance...).
>>
>> This has been present forever. So unless there is a real issue, I am
>> tempted to suggest to wait until the release is out and backport after.
>>
>> I will leave Oleksii the final decision.
> 
> I agree with your assessment. I am fine with deferring this until after the
> release unless Oleksii decides otherwise.
> 
> The patch is not fixing any known issue and was only intended to align the
> guest entry state with the documented requirements.
If it isn't fixing any known issue then lets defer this patch until 4.22 
will be released.

Thanks.

~ Oleksii