All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: Drop RDPID macro to discourage use of RDPID in the kernel
@ 2020-10-27 21:45 Sean Christopherson
  2020-10-28  8:54 ` Peter Zijlstra
  2020-11-26 12:14 ` [tip: x86/cleanups] x86/asm: Drop unused RDPID macro tip-bot2 for Sean Christopherson
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2020-10-27 21:45 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86
  Cc: H. Peter Anvin, linux-kernel, Sean Christopherson

Drop the GAS-compatible RDPID macro as RDPID shouldn't be used in the
kernel, excepting the vDSO, which handcodes RDPID in inline asm.  RDPID
is unsafe in the kernel because KVM loads guest's TSC_AUX on VM-entry
and may not restore the host's value until the CPU returns to userspace.

See commit 6a3ea3e68b8a ("x86/entry/64: Do not use RDPID in paranoid
entry to accomodate KVM") for details.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/include/asm/inst.h | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/arch/x86/include/asm/inst.h b/arch/x86/include/asm/inst.h
index bd7f02480ca1..438ccd4f3cc4 100644
--- a/arch/x86/include/asm/inst.h
+++ b/arch/x86/include/asm/inst.h
@@ -143,21 +143,6 @@
 	.macro MODRM mod opd1 opd2
 	.byte \mod | (\opd1 & 7) | ((\opd2 & 7) << 3)
 	.endm
-
-.macro RDPID opd
-	REG_TYPE rdpid_opd_type \opd
-	.if rdpid_opd_type == REG_TYPE_R64
-	R64_NUM rdpid_opd \opd
-	.else
-	R32_NUM rdpid_opd \opd
-	.endif
-	.byte 0xf3
-	.if rdpid_opd > 7
-	PFX_REX rdpid_opd 0
-	.endif
-	.byte 0x0f, 0xc7
-	MODRM 0xc0 rdpid_opd 0x7
-.endm
 #endif
 
 #endif
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: Drop RDPID macro to discourage use of RDPID in the kernel
  2020-10-27 21:45 [PATCH] x86: Drop RDPID macro to discourage use of RDPID in the kernel Sean Christopherson
@ 2020-10-28  8:54 ` Peter Zijlstra
  2020-11-26 12:14 ` [tip: x86/cleanups] x86/asm: Drop unused RDPID macro tip-bot2 for Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2020-10-28  8:54 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, linux-kernel

On Tue, Oct 27, 2020 at 02:45:32PM -0700, Sean Christopherson wrote:
> Drop the GAS-compatible RDPID macro as RDPID shouldn't be used in the
> kernel, excepting the vDSO, which handcodes RDPID in inline asm.  RDPID
> is unsafe in the kernel because KVM loads guest's TSC_AUX on VM-entry
> and may not restore the host's value until the CPU returns to userspace.
> 
> See commit 6a3ea3e68b8a ("x86/entry/64: Do not use RDPID in paranoid
> entry to accomodate KVM") for details.

Well, remove it because there is no (current) user, OK. But if there's a
compelling kernel side use for it, KVM can go suck rocks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: x86/cleanups] x86/asm: Drop unused RDPID macro
  2020-10-27 21:45 [PATCH] x86: Drop RDPID macro to discourage use of RDPID in the kernel Sean Christopherson
  2020-10-28  8:54 ` Peter Zijlstra
@ 2020-11-26 12:14 ` tip-bot2 for Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Sean Christopherson @ 2020-11-26 12:14 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Sean Christopherson, Borislav Petkov, x86, linux-kernel

The following commit has been merged into the x86/cleanups branch of tip:

Commit-ID:     8539d3f06710a9e91b9968fa736549d7c6b44206
Gitweb:        https://git.kernel.org/tip/8539d3f06710a9e91b9968fa736549d7c6b44206
Author:        Sean Christopherson <sean.j.christopherson@intel.com>
AuthorDate:    Tue, 27 Oct 2020 14:45:32 -07:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Thu, 26 Nov 2020 12:58:56 +01:00

x86/asm: Drop unused RDPID macro

Drop the GAS-compatible RDPID macro. RDPID is unsafe in the kernel
because KVM loads guest's TSC_AUX on VM-entry and may not restore the
host's value until the CPU returns to userspace.

See

  6a3ea3e68b8a ("x86/entry/64: Do not use RDPID in paranoid entry to accomodate KVM")

for details.

It can always be resurrected from git history, if needed.

 [ bp: Massage commit message. ]

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20201027214532.1792-1-sean.j.christopherson@intel.com
---
 arch/x86/include/asm/inst.h | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/arch/x86/include/asm/inst.h b/arch/x86/include/asm/inst.h
index bd7f024..438ccd4 100644
--- a/arch/x86/include/asm/inst.h
+++ b/arch/x86/include/asm/inst.h
@@ -143,21 +143,6 @@
 	.macro MODRM mod opd1 opd2
 	.byte \mod | (\opd1 & 7) | ((\opd2 & 7) << 3)
 	.endm
-
-.macro RDPID opd
-	REG_TYPE rdpid_opd_type \opd
-	.if rdpid_opd_type == REG_TYPE_R64
-	R64_NUM rdpid_opd \opd
-	.else
-	R32_NUM rdpid_opd \opd
-	.endif
-	.byte 0xf3
-	.if rdpid_opd > 7
-	PFX_REX rdpid_opd 0
-	.endif
-	.byte 0x0f, 0xc7
-	MODRM 0xc0 rdpid_opd 0x7
-.endm
 #endif
 
 #endif

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-26 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 21:45 [PATCH] x86: Drop RDPID macro to discourage use of RDPID in the kernel Sean Christopherson
2020-10-28  8:54 ` Peter Zijlstra
2020-11-26 12:14 ` [tip: x86/cleanups] x86/asm: Drop unused RDPID macro tip-bot2 for Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.