Index | Thread | Search

From:
Jonathan Gray <jsg@jsg.id.au>
Subject:
Re: silicon debug check
To:
Daniel Dickman <didickman@gmail.com>
Cc:
tech@openbsd.org
Date:
Mon, 28 Sep 2026 13:50:22 +1000

Download raw body.

Thread
On Sun, Sep 27, 2026 at 11:15:25PM -0400, Daniel Dickman wrote:
> Could the closing bracket be misplaced?
> 
> It looks like the silicon debug check only runs inside the fast strings 
> block.

a mistake made by robert when moving code around

wasn't done to i386, only amd64

src/sys/arch/amd64/amd64/cpu.c 1.159

	if (strcmp(cpu_vendor, "GenuineIntel") == 0 &&
	    (family > 6 || (family == 6 && ci->ci_model >= 0xd)) &&
	    rdmsr_safe(MSR_MISC_ENABLE, &msr) == 0 &&
	    (msr & MISC_ENABLE_FAST_STRINGS) == 0) {
		msr |= MISC_ENABLE_FAST_STRINGS;
		wrmsr(MSR_MISC_ENABLE, msr);
		DPRINTF("%s: enabled fast strings\n", ci->ci_dev->dv_xname);
	}

src/sys/arch/amd64/amd64/identcpu.c 1.127

	if (!strcmp(cpu_vendor, "GenuineIntel") &&
	    (cpu_ecxfeature & CPUIDECX_SDBG)) {
		uint64_t msr;

		msr = rdmsr(IA32_DEBUG_INTERFACE);
		if ((msr & IA32_DEBUG_INTERFACE_ENABLE) &&
		    (msr & IA32_DEBUG_INTERFACE_LOCK) == 0) {
			msr &= IA32_DEBUG_INTERFACE_MASK;
			msr |= IA32_DEBUG_INTERFACE_LOCK;
			wrmsr(IA32_DEBUG_INTERFACE, msr);
		} else if (msr & IA32_DEBUG_INTERFACE_ENABLE)
			printf("%s: cannot disable silicon debug\n",
			    ci->ci_dev->dv_xname);
	}

> 
> Index: cpu.c
> ===================================================================
> RCS file: /home/cvs/src/sys/arch/amd64/amd64/cpu.c,v
> diff -u -p -u -r1.206 cpu.c
> --- cpu.c	14 May 2026 01:39:38 -0000	1.206
> +++ cpu.c	28 Sep 2026 03:07:48 -0000
> @@ -1253,7 +1253,8 @@ cpu_fix_msrs(struct cpu_info *ci)
>  			msr |= MISC_ENABLE_FAST_STRINGS;
>  			wrmsr(MSR_MISC_ENABLE, msr);
>  			DPRINTF("%s: enabled fast strings\n", ci->ci_dev->dv_xname);
> -	
> +		}
> +
>  		/*
>  		 * Attempt to disable Silicon Debug and lock the configuration
>  		 * if it's enabled and unlocked.
> @@ -1268,7 +1269,6 @@ cpu_fix_msrs(struct cpu_info *ci)
>  			} else if (msr & IA32_DEBUG_INTERFACE_ENABLE)
>  				printf("%s: cannot disable silicon debug\n",
>  				    ci->ci_dev->dv_xname);
> -			}
>  		}
>  	}

I'd prefer

Index: sys/arch/amd64/amd64/cpu.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
diff -u -p -r1.206 cpu.c
--- sys/arch/amd64/amd64/cpu.c	14 May 2026 01:39:38 -0000	1.206
+++ sys/arch/amd64/amd64/cpu.c	28 Sep 2026 03:46:07 -0000
@@ -1253,7 +1253,8 @@ cpu_fix_msrs(struct cpu_info *ci)
 			msr |= MISC_ENABLE_FAST_STRINGS;
 			wrmsr(MSR_MISC_ENABLE, msr);
 			DPRINTF("%s: enabled fast strings\n", ci->ci_dev->dv_xname);
-	
+		}
+
 		/*
 		 * Attempt to disable Silicon Debug and lock the configuration
 		 * if it's enabled and unlocked.
@@ -1265,7 +1266,7 @@ cpu_fix_msrs(struct cpu_info *ci)
 				msr &= IA32_DEBUG_INTERFACE_MASK;
 				msr |= IA32_DEBUG_INTERFACE_LOCK;
 				wrmsr(IA32_DEBUG_INTERFACE, msr);
-			} else if (msr & IA32_DEBUG_INTERFACE_ENABLE)
+			} else if (msr & IA32_DEBUG_INTERFACE_ENABLE) {
 				printf("%s: cannot disable silicon debug\n",
 				    ci->ci_dev->dv_xname);
 			}