[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ee01b8d6-ee0c-b17d-1969-4aed41fa8666@suse.com>
Date: Tue, 4 Oct 2022 17:33:58 +0200
From: Juergen Gross <jgross@...e.com>
To: Jan Beulich <jbeulich@...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.22 13:03, Jan Beulich wrote:
> 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.
And on bare metal write_msr_safe() will return -EIO, too.
Juergen
Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3099 bytes)
Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)
Powered by blists - more mailing lists