[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] arch: arm64: always set EL=1 when injecting undefined exception


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Thu, 13 Feb 2025 12:13:18 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F1Iq0emRXi6rsbGfOh86r7xvMmidAmSibWXeYMYF6eI=; b=qfeX/VprwD5eCSnY1ll4+fl6Q06e6Xv971/+8MnTZmsp0z5XtEHryAdfSQrQTOp9DVriawB7Ba5YdOoyNkOzft/BQsEI+LeqDoOrU2eMC/1lJ5dz9zbHqzJbZiiV2Rw5jtduuQHkgXBV/UPAg9Fs2N7stqjn075xNJZiEi/W6uD6+Kstt0B4+Dl1DsRLQp733DR/JYQsG3riH/fFoBM4mwFupm7uztfZZPZQBF1xWzL+YRCU0mkxj5qMepd4Hp5JYg65OvmQsiScKLjeQkaouncXWc8lNzGF5i38IYndSg5Gza86+HW+2NlHiC6ORDene7EZ9zcG/IKHe2ae5plSwQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DZw8e+h63ggEd8stDE91M9J2Ka7VZI4aP6n00r7khYcPacE7fb5qFYiFXOrKRKaAAHJ03G7cQxQ/JPSXahtzYqzo6KVNoDPE4ADTon/t5nVVzGbimQ2apF2YfIQJmJSLqPYJ7bRjkUNwd2UbYDqQ1jkQVqbjNjiLVmgGjTOZY8dED9NBFleGXdH+4e/y76pJIh2WO5nr2jQBeHyHI36ggtvt0YFUW2S65IsDR46wMPQMs/tvWs+j2GpSxb7rAetS4vvxLBJN99J/dQT2M+2ev0k+jlwLiqHUpQXyFX6oSS18jOR9VU4mibQo1ciMrcMKGb0vfIPQtBXova9o+nLvsg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Delivery-date: Thu, 13 Feb 2025 11:13:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

You seem to have accidentally dropped xen-devel. Re-adding.

On 13/02/2025 12:04, Volodymyr Babchuk wrote:
> 
> 
> Hi Michal,
> 
> "Orzel, Michal" <michal.orzel@xxxxxxx> writes:
> 
>> Hi Volodymyr,
>>
>> NIT: s/EL/IL/ in commit title
> 
> Sure, thanks.
> 
>> One remark below.
>>
>> On 12/02/2025 23:03, Stefano Stabellini wrote:
>>>
>>>
>>> On Wed, 12 Feb 2025, Volodymyr Babchuk wrote:
>>>> ARM Architecture Reference Manual states that EL field of ESR_EL1
>>>> register should be 1 when EC is 0b000000 aka HSR_EC_UNKNOWN.
>>>>
>>>> Section D24.2.40, page D24-7337 of ARM DDI 0487L:
>>>>
>>>>   IL, bit [25]
>>>>   Instruction Length for synchronous exceptions. Possible values of this 
>>>> bit are:
>>>>
>>>>   [...]
>>>>
>>>>   0b1 - 32-bit instruction trapped.
>>>>   This value is also used when the exception is one of the following:
>>>>   [...]
>>>>    - An exception reported using EC value 0b000000.
>>>>
>>>> To align code with the specification, set .len field to 1 in
>>>> inject_undef64_exception() and remove unneeded second parameter.
>>>>
>>>> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
>>>
>>> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
>>>
>>>
>>>> ---
>>>>  xen/arch/arm/arm64/vsysreg.c           |  8 ++++----
>>>>  xen/arch/arm/include/asm/arm64/traps.h |  2 +-
>>>>  xen/arch/arm/include/asm/traps.h       |  2 +-
>>>>  xen/arch/arm/p2m.c                     |  2 +-
>>>>  xen/arch/arm/traps.c                   | 24 ++++++++++++------------
>>>>  xen/arch/arm/vcpreg.c                  | 24 ++++++++++++------------
>>>>  xen/arch/arm/vsmc.c                    |  6 ++----
>>>>  7 files changed, 33 insertions(+), 35 deletions(-)
>>>>
>>>> diff --git a/xen/arch/arm/arm64/vsysreg.c b/xen/arch/arm/arm64/vsysreg.c
>>>> index c73b2c95ce..29622a8593 100644
>>>> --- a/xen/arch/arm/arm64/vsysreg.c
>>>> +++ b/xen/arch/arm/arm64/vsysreg.c
>>>> @@ -95,7 +95,7 @@ void do_sysreg(struct cpu_user_regs *regs,
>>>>       */
>>>>      case HSR_SYSREG_ACTLR_EL1:
>>>>          if ( regs_mode_is_user(regs) )
>>>> -            return inject_undef_exception(regs, hsr);
>>>> +            return inject_undef_exception(regs);
>>>>          if ( hsr.sysreg.read )
>>>>              set_user_reg(regs, regidx, v->arch.actlr);
>>>>          break;
>>>> @@ -267,7 +267,7 @@ void do_sysreg(struct cpu_user_regs *regs,
>>>>      case HSR_SYSREG_CNTP_TVAL_EL0:
>>>>      case HSR_SYSREG_CNTP_CVAL_EL0:
>>>>          if ( !vtimer_emulate(regs, hsr) )
>>>> -            return inject_undef_exception(regs, hsr);
>>>> +            return inject_undef_exception(regs);
>>>>          break;
>>>>
>>>>      /*
>>>> @@ -280,7 +280,7 @@ void do_sysreg(struct cpu_user_regs *regs,
>>>>      case HSR_SYSREG_ICC_SGI0R_EL1:
>>>>
>>>>          if ( !vgic_emulate(regs, hsr) )
>>>> -            return inject_undef64_exception(regs, hsr.len);
>>>> +            return inject_undef64_exception(regs);
>>>>          break;
>>>>
>>>>      /*
>>>> @@ -440,7 +440,7 @@ void do_sysreg(struct cpu_user_regs *regs,
>>>>      gdprintk(XENLOG_ERR,
>>>>               "unhandled 64-bit sysreg access %#"PRIregister"\n",
>>>>               hsr.bits & HSR_SYSREG_REGS_MASK);
>>>> -    inject_undef_exception(regs, hsr);
>>>> +    inject_undef_exception(regs);
>>>>  }
>>>>
>>>>  /*
>>>> diff --git a/xen/arch/arm/include/asm/arm64/traps.h 
>>>> b/xen/arch/arm/include/asm/arm64/traps.h
>>>> index a347cb13d6..3be2fa69ee 100644
>>>> --- a/xen/arch/arm/include/asm/arm64/traps.h
>>>> +++ b/xen/arch/arm/include/asm/arm64/traps.h
>>>> @@ -1,7 +1,7 @@
>>>>  #ifndef __ASM_ARM64_TRAPS__
>>>>  #define __ASM_ARM64_TRAPS__
>>>>
>>>> -void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len);
>>>> +void inject_undef64_exception(struct cpu_user_regs *regs);
>>>>
>>>>  void do_sysreg(struct cpu_user_regs *regs,
>>>>                 const union hsr hsr);
>>>> diff --git a/xen/arch/arm/include/asm/traps.h 
>>>> b/xen/arch/arm/include/asm/traps.h
>>>> index 9a60dbf70e..3b40afe262 100644
>>>> --- a/xen/arch/arm/include/asm/traps.h
>>>> +++ b/xen/arch/arm/include/asm/traps.h
>>>> @@ -44,7 +44,7 @@ int check_conditional_instr(struct cpu_user_regs *regs, 
>>>> const union hsr hsr);
>>>>
>>>>  void advance_pc(struct cpu_user_regs *regs, const union hsr hsr);
>>>>
>>>> -void inject_undef_exception(struct cpu_user_regs *regs, const union hsr 
>>>> hsr);
>>>> +void inject_undef_exception(struct cpu_user_regs *regs);
>>>>
>>>>  /* read as zero and write ignore */
>>>>  void handle_raz_wi(struct cpu_user_regs *regs, int regidx, bool read,
>>>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>>>> index 65b70955e3..6196cad0d4 100644
>>>> --- a/xen/arch/arm/p2m.c
>>>> +++ b/xen/arch/arm/p2m.c
>>>> @@ -438,7 +438,7 @@ void p2m_set_way_flush(struct vcpu *v, struct 
>>>> cpu_user_regs *regs,
>>>>      {
>>>>          gprintk(XENLOG_ERR,
>>>>                  "The cache should be flushed by VA rather than by 
>>>> set/way.\n");
>>>> -        inject_undef_exception(regs, hsr);
>>>> +        inject_undef_exception(regs);
>> There's nothing using hsr anymore, so you should drop hsr parameter from
>> p2m_set_way_flush()
> 
> You are right, I'll do this in the second version. It is strange that
> compiler didn't warn me about unused parameter, though...
You would need to explicitly set -Wunused-parameter in EXTRA_CFLAGS_XEN_CORE.
There are other issues there though.

> 
>> BTW. Are you going to also look at simplifying e.g. inject_iabt_exception() 
>> for
>> which IL is also 1?
> 
> Yes, I'll add a separate patch in the next version.
> 
> --
> WBR, Volodymyr

~Michal




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.