lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjomvjFNjGADmu6l@google.com>
Date:   Tue, 22 Mar 2022 19:42:54 +0000
From:   Oliver Upton <oupton@...gle.com>
To:     Gavin Shan <gshan@...hat.com>
Cc:     kvmarm@...ts.cs.columbia.edu, maz@...nel.org,
        linux-kernel@...r.kernel.org, eauger@...hat.com,
        shan.gavin@...il.com, Jonathan.Cameron@...wei.com,
        pbonzini@...hat.com, vkuznets@...hat.com, will@...nel.org
Subject: Re: [PATCH v5 01/22] KVM: arm64: Introduce template for inline
 functions

Hi Gavin,

On Tue, Mar 22, 2022 at 04:06:49PM +0800, Gavin Shan wrote:
> The inline functions used to get the SMCCC parameters have same
> layout. It means these functions can be presented by an unified
> template, to make the code simplified. Besides, this adds more
> similar inline functions like smccc_get_arg{4,5,6,7,8}() to get
> more SMCCC arguments, which are needed by SDEI virtualization
> support.
> 
> Signed-off-by: Gavin Shan <gshan@...hat.com>
> ---
>  include/kvm/arm_hypercalls.h | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h
> index 0e2509d27910..d5144c852fe4 100644
> --- a/include/kvm/arm_hypercalls.h
> +++ b/include/kvm/arm_hypercalls.h
> @@ -13,20 +13,20 @@ static inline u32 smccc_get_function(struct kvm_vcpu *vcpu)
>  	return vcpu_get_reg(vcpu, 0);
>  }
>  
> -static inline unsigned long smccc_get_arg1(struct kvm_vcpu *vcpu)
> -{
> -	return vcpu_get_reg(vcpu, 1);
> -}
> -
> -static inline unsigned long smccc_get_arg2(struct kvm_vcpu *vcpu)
> -{
> -	return vcpu_get_reg(vcpu, 2);
> +#define SMCCC_DECLARE_GET_ARG(reg)					\
> +static inline unsigned long smccc_get_arg##reg(struct kvm_vcpu *vcpu)	\
> +{									\
> +	return vcpu_get_reg(vcpu, reg);					\
>  }
>  
> -static inline unsigned long smccc_get_arg3(struct kvm_vcpu *vcpu)
> -{
> -	return vcpu_get_reg(vcpu, 3);
> -}
> +SMCCC_DECLARE_GET_ARG(1)
> +SMCCC_DECLARE_GET_ARG(2)
> +SMCCC_DECLARE_GET_ARG(3)
> +SMCCC_DECLARE_GET_ARG(4)
> +SMCCC_DECLARE_GET_ARG(5)
> +SMCCC_DECLARE_GET_ARG(6)
> +SMCCC_DECLARE_GET_ARG(7)
> +SMCCC_DECLARE_GET_ARG(8)

Hmm. What if we specify a single inline function where the caller passes
the arg # as a parameter? We really just want to abstract away the
off-by-one difference between GP registers and SMCCC arguments.

Macros generally make me uneasy for template functions, but I may be in
the vocal minority on this topic :)

--
Thanks,
Oliver

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ