Re: [PATCH v2 2/2] x86/traps: Initialize DR7 by writing its architectural reset value

From: Sohil Mehta
Date: Tue Jun 17 2025 - 19:11:07 EST


On 6/17/2025 12:32 AM, Xin Li (Intel) wrote:
> Initialize DR7 by writing its architectural reset value to ensure
> compliance with the specification.
>
> Reviewed-by: H. Peter Anvin (Intel) <hpa@xxxxxxxxx>
> Signed-off-by: Xin Li (Intel) <xin@xxxxxxxxx>
> ---
>
> Changes in v2:
> *) Use debug register index 7 rather than DR_CONTROL (PeterZ and Sean).
> *) Use DR7_FIXED_1 as the architectural reset value of DR7 (Sean).
> ---
> arch/x86/include/asm/debugreg.h | 14 ++++++++++----
> arch/x86/include/asm/kvm_host.h | 2 +-
> arch/x86/kernel/cpu/common.c | 2 +-
> arch/x86/kernel/kgdb.c | 2 +-
> arch/x86/kernel/process_32.c | 2 +-
> arch/x86/kernel/process_64.c | 2 +-
> arch/x86/kvm/x86.c | 4 ++--
> 7 files changed, 17 insertions(+), 11 deletions(-)
>

With the updated commit message suggested by Sean,

Reviewed-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>


> diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h
> index 363110e6b2e3..3acb85850c19 100644
> --- a/arch/x86/include/asm/debugreg.h
> +++ b/arch/x86/include/asm/debugreg.h
> @@ -9,6 +9,9 @@
> #include <asm/cpufeature.h>
> #include <asm/msr.h>
>
> +/* DR7_FIXED_1 is also used as the init/reset value for DR7 */
> +#define DR7_FIXED_1 0x00000400
> +

Did you mean to describe what DR7_FIXED_1 is, and then say it is also
used as the init/reset value? Because the way the comment is framed
right now, it seems something is missing.

> DECLARE_PER_CPU(unsigned long, cpu_dr7);
>