Re: [PATCH v1 1/3] x86/traps: Move DR7_RESET_VALUE to <uapi/asm/debugreg.h>

From: Xin Li
Date: Fri Jun 13 2025 - 17:39:36 EST


On 6/13/2025 1:03 PM, Sean Christopherson wrote:
On Fri, Jun 13, 2025, Xin Li wrote:
On 6/13/2025 7:18 AM, Sean Christopherson wrote:
On Fri, Jun 13, 2025, Xin Li (Intel) wrote:
Move DR7_RESET_VALUE to <uapi/asm/debugreg.h> to prepare to write DR7
with DR7_RESET_VALUE at boot time.

Alternatively, what about dropping DR7_RESET_VALUE, moving KVM's DR6 and DR7
#defines out of arch/x86/include/asm/kvm_host.h, and then using DR7_FIXED_1?

We definitely should do it, I see quite a few architectural definitions
are in KVM only headers (the native FRED patches needed to reuse the event
types that were previously VMX-specific and moved them out of KVM
headers).

Because there is an UAPI header, we probably don't want to remove
definitions from it?

What #defines are in which uapi header?

arch/x86/include/uapi/asm/debugreg.h has:

#define DR_BUS_LOCK (0x800) /* bus_lock */
#define DR_STEP (0x4000) /* single-step */
#define DR_SWITCH (0x8000) /* task switch */

And arch/x86/include/asm/kvm_host.h also has:

#define DR6_BUS_LOCK (1 << 11)
#define DR6_BD (1 << 13)
#define DR6_BS (1 << 14)
#define DR6_BT (1 << 15)
#define DR6_RTM (1 << 16)

Duplicated definitions for the same DR6 bits.