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] [day] [month] [year] [list]
Date:   Tue, 8 Jan 2019 17:11:22 +0100
From:   Christophe de Dinechin <cdupontd@...hat.com>
To:     Yang Weijiang <weijiang.yang@...el.com>
Cc:     qemu-devel@...gnu.org, Paolo Bonzini <pbonzini@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>,
        open list <linux-kernel@...r.kernel.org>,
        KVM list <kvm@...r.kernel.org>,
        "Michael S. Tsirkin" <mst@...hat.com>, yu-cheng.yu@...el.com,
        yi.z.zhang@...el.com, hjl.tools@...il.com,
        Zhang Yi <yi.z.zhang@...ux.intel.com>
Subject: Re: [Qemu-devel][PATCH 3/4] Add hepler functions for CPUID xsave area
 size calculation.

Typo in subject line (helper)

> On 26 Dec 2018, at 09:25, Yang Weijiang <weijiang.yang@...el.com> wrote:
> 
> These functions are called when return CPUID xsave area
> size information.
> 
> Signed-off-by: Zhang Yi <yi.z.zhang@...ux.intel.com>
> Signed-off-by: Yang Weijiang <weijiang.yang@...el.com>
> ---
> target/i386/cpu.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 3630c688d6..cf4f2798dc 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -1281,12 +1281,34 @@ static inline bool accel_uses_host_cpuid(void)
>     return kvm_enabled() || hvf_enabled();
> }
> 
> +static uint32_t xsave_area_size_compat(uint64_t mask)

Just curious, why “compat”?

> +{
> +    int i;
> +    uint64_t ret = 0;
> +    uint32_t offset;
> +
> +    for (i = 0; i < ARRAY_SIZE(x86_ext_save_areas); i++) {
> +        const ExtSaveArea *esa = &x86_ext_save_areas[i];
> +        offset = i > 1 ? ret : esa->offset;

What about a named constant instead of ‘1’?

(note that a loop around line 4657 starts at 2, so I guess it’s OK to use 1 here, or at least >= 2 ;-)


> +        if ((mask >> i) & 1) {
> +            ret = MAX(ret, offset + esa->size);
> +        }
> +    }
> +    return ret;
> +}
> +
> static inline uint64_t x86_cpu_xsave_components(X86CPU *cpu)
> {
>     return ((uint64_t)cpu->env.features[FEAT_XSAVE_COMP_HI]) << 32 |
>            cpu->env.features[FEAT_XSAVE_COMP_LO];
> }
> 
> +static inline uint64_t x86_cpu_xsave_sv_components(X86CPU *cpu)
> +{
> +    return ((uint64_t)cpu->env.features[FEAT_XSAVE_SV_HI]) << 32 |
> +           cpu->env.features[FEAT_XSAVE_SV_LO];
> +}
> +
> const char *get_register_name_32(unsigned int reg)
> {
>     if (reg >= CPU_NB_REGS32) {
> @@ -4913,8 +4935,10 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu)
>         }
>     }
> 
> -    env->features[FEAT_XSAVE_COMP_LO] = mask;
> +    env->features[FEAT_XSAVE_COMP_LO] = mask & CPUID_XSTATE_USER_MASK;
>     env->features[FEAT_XSAVE_COMP_HI] = mask >> 32;
> +    env->features[FEAT_XSAVE_SV_LO] = mask & CPUID_XSTATE_KERNEL_MASK;
> +    env->features[FEAT_XSAVE_SV_HI] = mask >> 32;
> }
> 
> /***** Steps involved on loading and filtering CPUID data
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ