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]
Date:   Tue, 4 Oct 2022 13:03:02 +0200
From:   Jan Beulich <jbeulich@...e.com>
To:     Juergen Gross <jgross@...e.com>
Cc:     Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>, xen-devel@...ts.xenproject.org,
        linux-kernel@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH v2 2/3] xen/pv: refactor msr access functions to support
 safe and unsafe accesses

On 04.10.2022 10:43, Juergen Gross wrote:
> Refactor and rename xen_read_msr_safe() and xen_write_msr_safe() to
> support both cases of MSR accesses, safe ones and potentially GP-fault
> generating ones.
> 
> This will prepare to no longer swallow GPs silently in xen_read_msr()
> and xen_write_msr().
> 
> Signed-off-by: Juergen Gross <jgross@...e.com>

Reviewed-by: Jan Beulich <jbeulich@...e.com>

Albeit ...

> @@ -933,23 +937,39 @@ static u64 xen_read_msr_safe(unsigned int msr, int *err)
>  	return val;
>  }
>  
> -static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
> +static void set_seg(unsigned int which, unsigned int low, unsigned int high,
> +		    int *err)
>  {
> -	int ret;
> -	unsigned int which;
> -	u64 base;
> +	u64 base = ((u64)high << 32) | low;
> +
> +	if (HYPERVISOR_set_segment_base(which, base) == 0)
> +		return;
>  
> -	ret = 0;
> +	if (err)
> +		*err = -EIO;

... I don't see a good reason to override the error code handed to us
by the hypervisor here; I do realize though that this ...

> +	else
> +		WARN(1, "Xen set_segment_base(%u, %llx) failed\n", which, base);
> +}
>  
> +/*
> + * Support write_msr_safe() and write_msr() semantics.
> + * With err == NULL write_msr() semantics are selected.
> + * Supplying an err pointer requires err to be pre-initialized with 0.
> + */
> +static void xen_do_write_msr(unsigned int msr, unsigned int low,
> +			     unsigned int high, int *err)
> +{
>  	switch (msr) {
> -	case MSR_FS_BASE:		which = SEGBASE_FS; goto set;
> -	case MSR_KERNEL_GS_BASE:	which = SEGBASE_GS_USER; goto set;
> -	case MSR_GS_BASE:		which = SEGBASE_GS_KERNEL; goto set;
> -
> -	set:
> -		base = ((u64)high << 32) | low;
> -		if (HYPERVISOR_set_segment_base(which, base) != 0)
> -			ret = -EIO;

... was this way before.

Jan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ