[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v10 03/38] x86/msr: Add the WRMSRNS instruction support
- To: Xin Li <xin3.li@xxxxxxxxx>, linux-doc@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-edac@xxxxxxxxxxxxxxx, linux-hyperv@xxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Nikolay Borisov <nik.borisov@xxxxxxxx>
- Date: Wed, 20 Sep 2023 10:58:13 +0300
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; 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=gqzAt/nNndS6ciIZ4al8oV2o0FAUsbEZseqb83RuJbY=; b=ZzpV7venmCETmrcC575+F8ProTW9iWSXvq/Kg18MDOfoopLDFZvQY3NIuoUezA3bTCOXa1x/x3l3KbpUYsEd04xi9vZRqTH8FqO++y05XyYvDmJaFBzvJ7JB9Wiy1mNaoFiSkWVUiCaj9G6bcGT/QiPkC1qfnfVL4s+8OXT3XzXlv90g/NTzaoPOUBB7f4HjAlVsZn9UyXnXOh2e0r0CoGwP1NJJnbcDZ6bGOKgj4c1gZuZXBl90j4p/RSDmTCmndlFku7GmmbqHCXkd6Czq0UQqonSOToajCUXBpCyNBJ0AVv1estUOKzkUeom+qdaGF0eZFCEjdWUYEW5QOLLXMw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WxQxgMpahAsdJhjj6Zpzme7qltUysMHyyhQWSxF07SEm4SOdtHUlG0eIS3LyYhbbPAHsjMHvvNvhUkMtxKl8hSEMrp4fA46kJnHvD9p56K75ryTK79K/HW3KfkkJFyiMgcg51r3iFsJ4ZbHWSVMrBbELnxoqllWrUCO6dwdOXwiOLisIcujhiAh59LR54zpQwXi5R2l0mtcXkPl3xVVZcr/xAZZzM6CTXdAWuX21vOHWiYqC9F3OC8WChd9UBqIr4H5yOuZ30B0PSdSJerD7Ml9AmDkWoDqBoktOZ+2OQW/z4CTHxad+0BxNw0LS4TnTg9UkciQBYgv9v3cIq/hcXA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: tglx@xxxxxxxxxxxxx, mingo@xxxxxxxxxx, bp@xxxxxxxxx, dave.hansen@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx, hpa@xxxxxxxxx, luto@xxxxxxxxxx, pbonzini@xxxxxxxxxx, seanjc@xxxxxxxxxx, peterz@xxxxxxxxxxxxx, jgross@xxxxxxxx, ravi.v.shankar@xxxxxxxxx, mhiramat@xxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, jiangshanlai@xxxxxxxxx
- Delivery-date: Wed, 20 Sep 2023 08:26:33 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 14.09.23 г. 7:47 ч., Xin Li wrote:
Add an always inline API __wrmsrns() to embed the WRMSRNS instruction
into the code.
Tested-by: Shan Kang <shan.kang@xxxxxxxxx>
Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
---
arch/x86/include/asm/msr.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 65ec1965cd28..c284ff9ebe67 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -97,6 +97,19 @@ static __always_inline void __wrmsr(unsigned int msr, u32
low, u32 high)
: : "c" (msr), "a"(low), "d" (high) : "memory");
}
+/*
+ * WRMSRNS behaves exactly like WRMSR with the only difference being
+ * that it is not a serializing instruction by default.
+ */
+static __always_inline void __wrmsrns(u32 msr, u32 low, u32 high)
Shouldn't this be named wrmsrns_safe since it has exception handling,
similar to the current wrmsrl_safe.
+{
+ /* Instruction opcode for WRMSRNS; supported in binutils >= 2.40. */
+ asm volatile("1: .byte 0x0f,0x01,0xc6\n"
+ "2:\n"
+ _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR)
+ : : "c" (msr), "a"(low), "d" (high));
+}
+
<snip>
|