[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86emul: recognize CLDEMOTE
- To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Tue, 25 Jan 2022 16:07:48 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=MsIe59JW2Q5UDiKGcwAZrE1MJ29ozAitMEwEe1GOFgg=; b=XRuS0cppK1L2GZcRFksM3Etff0VKBHVSdon/9ccZbCktCRF6bqsNM+bX8Mb2BlADPWqJCwpmCdcxgmqFswpWd66fJeb0987qUWlL3WtlvLLnOdzxLihr6i7SETbQXyVstg9res36Oa0gMHEiU94CaxhquKDB4gddPXHFY/Ihf5d5fx3YZeRdBvuW8w8BSZw2lhWZBlctwe0rLbt4SY2D3EwUSN5Yh7XV7RfD0Dvni2t2V5pB/kXQT0Nk/it5lELkgnEB9SILBnUztGN29yb4DR1MBrA8qbcjY+1HNZ7INBSakTrJFWwsssHxTLWr/m/GR448cetDZRxopKVJHoQVcA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YQyYJ8KJskm7r/bCh4LSpDl6ex4mgVqDiRGn/TtN4COj/8chVHi4dJBsM1jNDXdOkJtUjm9ec7c44b42lOXjpMPdBiAsi491dtWPpqp4ctzDP4JSici3QufkvjR7jYesTQryzBFIyPdUcqElTZ/aYsxgbbiXpI3i8LdBXlVbC9EzHeQgnIDevsp+pewNemJRe+qz3Nrz2N2tOzLuXuoarHHlcj3R9QR/1OI96iOVktDRdtsxz9/6V0C/RIGUCHPLa5XTDp03HrnnJlEFmGy47+8+hdKKjOlbTIdm9+1Yz1mZ2sdyUR/blPWGommHPKyfqtn1TzB8wtBWz5rN58Bi7w==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Tue, 25 Jan 2022 15:07:56 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 25.01.2022 15:35, Roger Pau Monné wrote:
> On Tue, Jan 25, 2022 at 03:22:25PM +0100, Jan Beulich wrote:
>> We claim to support the insn, but so far the emulator has been handling
>> it as a NOP.
>
> While not ideal, the SDM mentions that "The CLDEMOTE instruction may
> be ignored by hardware in certain cases and is not a guarantee.".
Right; the same is effectively the case for CLFLUSH etc. Still, unlike
prefetches, we implement them in the emulator.
>> --- a/xen/arch/x86/hvm/emulate.c
>> +++ b/xen/arch/x86/hvm/emulate.c
>> @@ -2351,6 +2351,28 @@ static int hvmemul_cache_op(
>> * to be sensibly used is in (virtualization unaware) firmware.
>> */
>> break;
>> +
>> + case x86emul_cldemote:
>> + ASSERT(!is_x86_system_segment(seg));
>> +
>> + if ( !boot_cpu_has(X86_FEATURE_CLDEMOTE) ||
>> + hvmemul_virtual_to_linear(seg, offset, 0, NULL,
>> hvm_access_none,
>> + hvmemul_ctxt, &addr) != X86EMUL_OKAY
>> )
>> + break;
>> +
>> + if ( hvmemul_ctxt->seg_reg[x86_seg_ss].dpl == 3 )
>> + pfec |= PFEC_user_mode;
>> +
>> + mapping = hvmemul_map_linear_addr(addr, 0, pfec, hvmemul_ctxt);
>
> I think the emulator should map the address using the same cache
> attributes as the guest, or else the result might be different than
> intended?
That's a pre-existing problem everywhere, not something specific to
this one insn.
Jan
|