diff mbox series

[Xen-devel,6/7] xen/arm: vsmc: The function identifier is always 32-bit

Message ID 20190723213553.22300-7-julien.grall@arm.com
State New
Headers show
Series xen/arm: Xen hardening for newer Armv8 | expand

Commit Message

Julien Grall July 23, 2019, 9:35 p.m. UTC
On Arm64, the SMCCC function identifier is always stored in the first 32-bit
of x0 register. The rest of the bits are not defined and should be
ignored.

This means the variable funcid should be an uint32_t rather than
register_t.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/vsmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Volodymyr Babchuk July 26, 2019, 12:39 p.m. UTC | #1
Julien Grall writes:

> On Arm64, the SMCCC function identifier is always stored in the first 32-bit
> of x0 register. The rest of the bits are not defined and should be
> ignored.
>
> This means the variable funcid should be an uint32_t rather than
> register_t.
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

> ---
>  xen/arch/arm/vsmc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c
> index f8e350311d..a36db15fff 100644
> --- a/xen/arch/arm/vsmc.c
> +++ b/xen/arch/arm/vsmc.c
> @@ -220,7 +220,7 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)
>  {
>      bool handled = false;
>      const union hsr hsr = { .bits = regs->hsr };
> -    register_t funcid = get_user_reg(regs, 0);
> +    uint32_t funcid = get_user_reg(regs, 0);
>  
>      /*
>       * Check immediate value for HVC32, HVC64 and SMC64.
> @@ -286,7 +286,7 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)
>  
>      if ( !handled )
>      {
> -        gprintk(XENLOG_INFO, "Unhandled SMC/HVC: %08"PRIregister"\n", funcid);
> +        gprintk(XENLOG_INFO, "Unhandled SMC/HVC: %#x\n", funcid);
>  
>          /* Inform caller that function is not supported. */
>          set_user_reg(regs, 0, ARM_SMCCC_ERR_UNKNOWN_FUNCTION);
Stefano Stabellini July 29, 2019, 10:13 p.m. UTC | #2
On Fri, 26 Jul 2019, Volodymyr Babchuk wrote:
> Julien Grall writes:
> 
> > On Arm64, the SMCCC function identifier is always stored in the first 32-bit
> > of x0 register. The rest of the bits are not defined and should be
> > ignored.
> >
> > This means the variable funcid should be an uint32_t rather than
> > register_t.
> >
> > Signed-off-by: Julien Grall <julien.grall@arm.com>
> Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

> > ---
> >  xen/arch/arm/vsmc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c
> > index f8e350311d..a36db15fff 100644
> > --- a/xen/arch/arm/vsmc.c
> > +++ b/xen/arch/arm/vsmc.c
> > @@ -220,7 +220,7 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)
> >  {
> >      bool handled = false;
> >      const union hsr hsr = { .bits = regs->hsr };
> > -    register_t funcid = get_user_reg(regs, 0);
> > +    uint32_t funcid = get_user_reg(regs, 0);
> >  
> >      /*
> >       * Check immediate value for HVC32, HVC64 and SMC64.
> > @@ -286,7 +286,7 @@ static bool vsmccc_handle_call(struct cpu_user_regs *regs)
> >  
> >      if ( !handled )
> >      {
> > -        gprintk(XENLOG_INFO, "Unhandled SMC/HVC: %08"PRIregister"\n", funcid);
> > +        gprintk(XENLOG_INFO, "Unhandled SMC/HVC: %#x\n", funcid);
> >  
> >          /* Inform caller that function is not supported. */
> >          set_user_reg(regs, 0, ARM_SMCCC_ERR_UNKNOWN_FUNCTION);
> 
> 
> -- 
> Volodymyr Babchuk at EPAM
diff mbox series

Patch

diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c
index f8e350311d..a36db15fff 100644
--- a/xen/arch/arm/vsmc.c
+++ b/xen/arch/arm/vsmc.c
@@ -220,7 +220,7 @@  static bool vsmccc_handle_call(struct cpu_user_regs *regs)
 {
     bool handled = false;
     const union hsr hsr = { .bits = regs->hsr };
-    register_t funcid = get_user_reg(regs, 0);
+    uint32_t funcid = get_user_reg(regs, 0);
 
     /*
      * Check immediate value for HVC32, HVC64 and SMC64.
@@ -286,7 +286,7 @@  static bool vsmccc_handle_call(struct cpu_user_regs *regs)
 
     if ( !handled )
     {
-        gprintk(XENLOG_INFO, "Unhandled SMC/HVC: %08"PRIregister"\n", funcid);
+        gprintk(XENLOG_INFO, "Unhandled SMC/HVC: %#x\n", funcid);
 
         /* Inform caller that function is not supported. */
         set_user_reg(regs, 0, ARM_SMCCC_ERR_UNKNOWN_FUNCTION);