[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] x86/emul: Remove fallback path from SWAPGS


  • To: Teddy Astie <teddy.astie@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 7 Apr 2026 17:25:05 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EZ/xf5DEBUxtzmm1/FDTwz6hEYJLWEaVwzn+F+MvuQg=; b=J1jrNG5g1k3ZQV+FyrZ9NsOG6IvonWfxMBDhPaeyx1wbzbROQWvQZ95PhHHXBsD2PyN3WDOY6lilq5bAm9/+a85dRCOrTP6mA28zM7g52Kk/8ugRZtP83HZVY/KlZSu5czIAHXR5TZ4CDWu8rIz4mkwqpLuipc+tpt7OjlVOLI1+J1ihryyTwTiiJcm0wbQuURB88YmtDFvD0jnB+8Fv5QgkbdjWKSPDlf8DHWI0iyxEa3EMPPRBe2yep9DiIRKNaUzoJTI25SUjL1aOUzR7SUPRS0A+9xbmmZUo+6cyjoNXV626oM4B37on3GKqTvmidTJ3h33NStTWpiLW33uiBA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Sw3n8lrI6aKmaGbrirCUhckpE0MqOtT4Gi0BFdmWzlCrx9ipTgeCCsrhUK5tA98ilEu8Zhcz6IsLiqaCCBna3nEGpxT7CFDow6eyYRtsoAcrtONQLeJUEZw0J97MmFPVfmgZtW/oLmKkBC0k9+hYqVlInapkO/tbxccsYCPN4J+OBYdo8wbkDIFnW5OugMrLZ8mLGuTmdJ/bi8kd4qaFqPz7STARRgfo5FHP9GMMhN7VWhe0ntPWst3GigrR1XqhN+i9K1fThc4crket+9IvPlALbE39BJ0QY5OKXF41LHsDlr27qFlr3PAlfLsF35IRs2/tdsTb/5gxtsPJclHjDg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 07 Apr 2026 16:25:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07/04/2026 5:00 pm, Teddy Astie wrote:
> Le 07/04/2026 à 16:27, Andrew Cooper a écrit :
>> In real hardware, accesses to the registers cannot fail.  The error paths are
>> just an artefact of the hook functions needing to return something.
>>
>> The best effort unwind is also something that doesn't exist in real hardware,
>> and makes the logic more complicated to follow.  Instead, use an
>> ASSERT_UNREACHABLE() with a fallback of injecting #DF.  Hitting this path is
>> an error in Xen.
>>
>> While adjusting, remove {read,write}_segment() and use {read,write}_msr() to
>> access MSR_GS_BASE.  There's no need to access the other parts of the GS
>> segment, and this is less work behind the scenes.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>> ---
>> CC: Jan Beulich <JBeulich@xxxxxxxx>
>> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>>
>> v2:
>>   * Retain x86_emul_reset_event()
>>   * Pass an error code for #DF
>>   * Drop goto done now that generate_exception() is used
>>   * Use 2x{read,write}_msr()
>>
>> Tested using LKGS's extention of the test emulator for SWAPGS.
>> ---
>>   xen/arch/x86/x86_emulate/0f01.c | 28 +++++++++++++++-------------
>>   1 file changed, 15 insertions(+), 13 deletions(-)
>>
>> diff --git a/xen/arch/x86/x86_emulate/0f01.c 
>> b/xen/arch/x86/x86_emulate/0f01.c
>> index 6c10979dd650..54bd6faf0f2c 100644
>> --- a/xen/arch/x86/x86_emulate/0f01.c
>> +++ b/xen/arch/x86/x86_emulate/0f01.c
>> @@ -189,22 +189,24 @@ int x86emul_0f01(struct x86_emulate_state *s,
>>           generate_exception_if(!mode_ring0(), X86_EXC_GP, 0);
>>           fail_if(!ops->read_segment || !ops->read_msr ||
>>                   !ops->write_segment || !ops->write_msr);
> Do we still need checks for ops->{read,write}_segment if we're not using 
> them anymore ?

Oh, yes they can be dropped now.

Please send a new patch.  I've already committed this to unblock some of
Jan's work.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.