feat(perf): default to NVMe, guard P-core pinning, add Win11 WHPX nested-virt patch

- Default newly created VMs to NVMe disk controller via reims-ctl set (supported by macOS Recovery, installer, and installed guests)
- Guard P-core affinity pinning with CanSafelyPinPCores (require P-core logical CPUs >= vmCPUs+1) to prevent XNU spinlock stalls on non-HT hybrid CPUs such as Intel Core Ultra 9 285H (6P/6T + 8E), and include logical thread counts in CPU pinning logs
- Add patches/qemu-whpx-nested-virt-nonfatal.patch (registered in patches/README.md & docs/portable-runtime-spec.md) to make WHvSetPartitionProperty(NestedVirtualization) hr=0x80370302 non-fatal so Win11 retains kernel-irqchip=on, and detect the patch in host optimizations and WHPX compat pre-apply
This commit is contained in:
Nwflower committed 2026-11-28 08:22:01 -07:00
1 parent 17497aee73
commit d42a4f85f0
15 files changed
+273 -38

No files matched your search

+40 -9
View File
@@ -109,7 +109,14 @@ func (a *App) pollVMs(ctx context.Context) {
if err != nil {
continue
}
type pinCandidate struct {
name string
pid int
}
var toPin []pinCandidate
a.mu.Lock()
loc := a.cfg.Locale
autoPin := a.cfg.AutoPinPCores
var b strings.Builder
for _, vm := range vms {
if tr, ok := a.transitions[vm.Name]; ok {
@@ -120,22 +127,46 @@ func (a *App) pollVMs(ctx context.Context) {
}
}
}
// Auto-pin P-cores once per running QEMU PID.
if a.cfg.AutoPinPCores && vm.State == "running" && vm.PID != nil && *vm.PID > 0 && !pinnedPIDs[*vm.PID] {
if autoPin && vm.State == "running" && vm.PID != nil && *vm.PID > 0 && !pinnedPIDs[*vm.PID] {
if cachedHost.HasHybridCores && cachedHost.PCoreMask > 0 {
if err := host.PinProcessToPCores(uint32(*vm.PID), cachedHost.PCoreMask); err == nil {
pinnedPIDs[*vm.PID] = true
a.emitLog(vm.Name, fmt.Sprintf("[CPU] Pinned QEMU (PID %d) to %d P-cores", *vm.PID, cachedHost.PCoreCount))
} else {
pinnedPIDs[*vm.PID] = true
a.emitLog(vm.Name, fmt.Sprintf("[CPU] Warning: P-core pinning failed for PID %d: %v", *vm.PID, err))
}
pinnedPIDs[*vm.PID] = true
toPin = append(toPin, pinCandidate{name: vm.Name, pid: *vm.PID})
}
}
fmt.Fprintf(&b, "%s:%s:%s;", vm.Name, vm.State, a.transitions[vm.Name])
}
sig := b.String()
a.mu.Unlock()
for _, cand := range toPin {
vmCPUs := 0
if c, cerr := a.client(); cerr == nil {
if det, derr := c.Show(ctx, cand.name); derr == nil {
vmCPUs = det.CPUs
}
}
safe, pThreads := host.CanSafelyPinPCores(cachedHost, vmCPUs)
if !safe {
if loc == i18n.ZhCN {
a.emitLog(cand.name, fmt.Sprintf("[CPU] 跳过 P 核绑定:虚拟机配置了 %d vCPU,而当前 CPU 仅有 %d 个 P 核(%d 个逻辑线程),强制绑核会引发核心超售与卡死,已使用全部核心运行",
vmCPUs, cachedHost.PCoreCount, pThreads))
} else {
a.emitLog(cand.name, fmt.Sprintf("[CPU] Skipped P-core pinning: VM has %d vCPUs, exceeding safe headroom for %d P-cores (%d logical CPUs); using all host CPUs to avoid spinlock stall",
vmCPUs, cachedHost.PCoreCount, pThreads))
}
continue
}
if err := host.PinProcessToPCores(uint32(cand.pid), cachedHost.PCoreMask); err == nil {
if loc == i18n.ZhCN {
a.emitLog(cand.name, fmt.Sprintf("[CPU] 已将 QEMU (PID %d) 绑定到 %d 个 P 核(%d 个逻辑线程,掩码 %s;未占用 %d 个 E 核)",
cand.pid, cachedHost.PCoreCount, pThreads, cachedHost.PCoreMaskHex, cachedHost.ECoreCount))
} else {
a.emitLog(cand.name, fmt.Sprintf("[CPU] Pinned QEMU (PID %d) to %d P-cores (%d logical CPUs, mask %s; %d E-cores excluded)",
cand.pid, cachedHost.PCoreCount, pThreads, cachedHost.PCoreMaskHex, cachedHost.ECoreCount))
}
} else {
a.emitLog(cand.name, fmt.Sprintf("[CPU] Warning: P-core pinning failed for PID %d: %v", cand.pid, err))
}
}
if sig != lastSig {
lastSig = sig
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
+9 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"github.com/Nwflower/reims-go/internal/driver/reims"
"github.com/Nwflower/reims-go/internal/installer"
@@ -63,11 +64,18 @@ func (a *App) createVMFlow(opts reims.CreateOpts) error {
}
err = c.Create(ctx, opts, w, w)
finishTask(err)
if err != nil {
finishTask(err)
a.emitLog(opts.Name, "Create error: "+err.Error())
return err
}
if dc := reims.EffectiveCreateDiskController(opts); dc != "ahci" {
a.emitLog(opts.Name, fmt.Sprintf("Setting disk controller for %s to %s...", opts.Name, strings.ToUpper(dc)))
if serr := c.Set(ctx, reims.SetOpts{Name: opts.Name, DiskController: dc}, w, w); serr != nil {
a.emitLog(opts.Name, fmt.Sprintf("Warning: could not switch disk controller to %s (keeping SATA/AHCI): %v", dc, serr))
}
}
finishTask(nil)
a.emitLog(opts.Name, "VM "+opts.Name+" ready.")
wailsRuntime.EventsEmit(a.ctx, "reims:state-changed", true)
if startAfterCreate {
+2
View File
@@ -105,6 +105,8 @@ reims-runtime-<commit>/
| 补丁 | 作用对象 | 解决的问题 | 状态 |
| :--- | :--- | :--- | :--- |
| `qemu-whpx-win10-compat.patch` | `vendor/qemu` 的 `target/i386/whpx/whpx-all.c` | ① `whpx_tsc_deadline_refused()`(`3210-3230`)原实现在真实分区上建、删 vCPU 0,Win10 19045 上随后 `whpx_init_vcpu()` 再次创建 vCPU 0 时必现 `WHvCreateVirtualProcessor` 返回 `E_INVALIDARG`(`hr=80070057`),改为独立临时探测分区;② `whpx_set_registers()`(`534`)直接调用 `WHvResetPartition` 未判空,Win10 19045 的 `WinHvPlatform.dll` 不导出该接口导致重置阶段必现 `0xc0000005 at 0x0` 崩溃(已核对导出表,10 个 supplemental API 中仅此一处漏判空) | 2026-11-28 实测复现并修复,待提交上游 PR(由人操作) |
| `qemu-whpx-win10-startup-ipis.patch` | 同上(在前一项之后应用) | Win10 开启内核 irqchip 时转发多核 INIT/SIPI,避免 XNU 从核启动停住 | 已合入补丁队列,客体冷重启待验证,待提交上游 PR |
| `qemu-whpx-nested-virt-nonfatal.patch` | 同上(在前两项之后应用) | 部分 Win11 宿主 `WHvSetPartitionProperty(NestedVirtualization)` 返回 `hr=0x80370302`(`WHV_E_UNKNOWN_PROPERTY`)导致 QEMU 在 `whpx-all.c:3479-3483` 直接致命退出,改为非致命警告并清零 `Bank1.NestedVirtSupport`,保留 `kernel-irqchip=on` 内核态 x2APIC 加速 | 2026-11-28 新增补丁,待编入下一版 candidate 运行时并在 Win11 真机冒烟验证后提 PR |
### 5.1 本机实测排障与待验证优化沉淀(2026-11-28,Win10 19045)
1. **Win10 下默认关闭 `kernel-irqchip` 导致高 CPU 开销(待验证优化)**:
+1
View File
@@ -338,6 +338,7 @@ export const App: React.FC = () => {
memory: `${recommendedMemoryGB(state.host)}G`,
disk_size: '128G',
disk_mode: 'copy',
disk_controller: 'nvme',
graphics: 'reims-vgpu',
gpu: state.host.recommended_gpu?.vulkan_icd ?? 'auto',
resolution: '1920x1080',
+38 -18
View File
@@ -57,6 +57,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
disk_size: '128G',
disk: '',
disk_mode: 'copy',
disk_controller: 'nvme',
graphics: 'reims-vgpu',
gpu: host.recommended_gpu?.vulkan_icd ?? 'auto',
resolution: '1920x1080',
@@ -305,27 +306,43 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
)}
{step === 3 && (
opts.source_mode !== 'disk' ? (
<>
{opts.source_mode !== 'disk' ? (
<div className="field">
<label className="field-label" htmlFor="vm-disk">{tr('diskSize')}</label>
{presets(['64G', '128G', '256G', '512G'], opts.disk_size, (s) => s, (disk_size) => set({ disk_size }))}
<input id="vm-disk" className="input" value={opts.disk_size ?? ''} onChange={(e) => set({ disk_size: e.target.value })} />
<span className="hint">{tr('diskSizeHint')}</span>
</div>
) : (
<div className="field">
<label className="field-label" htmlFor="vm-diskmode">{tr('diskMode')}</label>
<select
id="vm-diskmode"
className="select"
value={opts.disk_mode}
onChange={(e) => set({ disk_mode: e.target.value as 'copy' | 'in-place' })}
>
<option value="copy">{tr('diskModeCopy')}</option>
<option value="in-place">{tr('diskModeInPlace')}</option>
</select>
</div>
)}
<div className="field">
<label className="field-label" htmlFor="vm-disk">{tr('diskSize')}</label>
{presets(['64G', '128G', '256G', '512G'], opts.disk_size, (s) => s, (disk_size) => set({ disk_size }))}
<input id="vm-disk" className="input" value={opts.disk_size ?? ''} onChange={(e) => set({ disk_size: e.target.value })} />
<span className="hint">{tr('diskSizeHint')}</span>
</div>
) : (
<div className="field">
<label className="field-label" htmlFor="vm-diskmode">{tr('diskMode')}</label>
<label className="field-label" htmlFor="vm-diskctl">{tr('diskController')}</label>
<select
id="vm-diskmode"
id="vm-diskctl"
className="select"
value={opts.disk_mode}
onChange={(e) => set({ disk_mode: e.target.value as 'copy' | 'in-place' })}
value={opts.disk_controller ?? 'nvme'}
onChange={(e) => set({ disk_controller: e.target.value as 'nvme' | 'ahci' | 'virtio' })}
>
<option value="copy">{tr('diskModeCopy')}</option>
<option value="in-place">{tr('diskModeInPlace')}</option>
<option value="nvme">NVMe ({locale === 'zh-CN' ? '推荐' : 'Recommended'})</option>
<option value="ahci">SATA (AHCI)</option>
{opts.source_mode === 'disk' && <option value="virtio">VirtIO</option>}
</select>
<span className="hint">{tr('diskControllerNvmeHint')}</span>
</div>
)
</>
)}
{step === 4 && (
@@ -499,9 +516,12 @@ const Review: React.FC<ReviewProps> = ({ locale, host, opts, issues, checking, c
{
step: 3,
title: 'step3',
rows: opts.source_mode !== 'disk'
? [{ label: tr('diskSize'), value: tr('summaryDiskGrow', { size: formatMemory(opts.disk_size ?? '') }) }]
: [{ label: tr('diskMode'), value: tr(opts.disk_mode === 'in-place' ? 'diskModeInPlace' : 'diskModeCopy') }],
rows: [
...(opts.source_mode !== 'disk'
? [{ label: tr('diskSize'), value: tr('summaryDiskGrow', { size: formatMemory(opts.disk_size ?? '') }) }]
: [{ label: tr('diskMode'), value: tr(opts.disk_mode === 'in-place' ? 'diskModeInPlace' : 'diskModeCopy') }]),
{ label: tr('diskController'), value: (opts.disk_controller ?? 'nvme').toUpperCase() === 'AHCI' ? 'SATA' : (opts.disk_controller ?? 'nvme').toUpperCase() },
],
},
{
step: 4,
+1
View File
@@ -154,6 +154,7 @@ export interface CreateOpts {
disk_size?: string
disk?: string
disk_mode?: 'copy' | 'in-place'
disk_controller?: 'nvme' | 'ahci' | 'virtio'
graphics: 'reims-vgpu' | 'vmware-svga'
gpu: string
resolution: string
+2
View File
@@ -374,6 +374,7 @@ export namespace reims {
disk_size?: string;
disk?: string;
disk_mode?: string;
disk_controller?: string;
graphics?: string;
gpu?: string;
resolution?: string;
@@ -402,6 +403,7 @@ export namespace reims {
this.disk_size = source["disk_size"];
this.disk = source["disk"];
this.disk_mode = source["disk_mode"];
this.disk_controller = source["disk_controller"];
this.graphics = source["graphics"];
this.gpu = source["gpu"];
this.resolution = source["resolution"];
+23 -1
View File
@@ -17,6 +17,7 @@ import (
"github.com/Nwflower/reims-go/internal/host"
"github.com/Nwflower/reims-go/internal/i18n"
"github.com/Nwflower/reims-go/internal/installer"
rt "github.com/Nwflower/reims-go/internal/runtime"
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
)
@@ -67,13 +68,34 @@ func isRecoveryModeActive(d reims.VMDetail) bool {
return m == "on" || m == "want"
}
func (a *App) activeRuntimeHasPatch(substr string) bool {
a.mu.Lock()
cfgCopy := *a.cfg
a.mu.Unlock()
active, err := rt.ResolveActive(&cfgCopy)
if err != nil || active == nil {
return false
}
needle := strings.ToLower(substr)
for _, p := range active.Manifest.Patches {
if strings.Contains(strings.ToLower(p.Name), needle) {
return true
}
}
return false
}
// applyProbedWHPXCompat pre-applies `-machine kernel-irqchip=off` on Windows 11
// builds where WHvPartitionPropertyCodeNestedVirtualization is probed as
// unsupported (e.g. hr=0x80370302), avoiding a noisy first-start crash & retry.
// unsupported (e.g. hr=0x80370302) AND the active runtime lacks
// qemu-whpx-nested-virt-nonfatal.patch, avoiding a noisy first-start crash & retry.
func (a *App) applyProbedWHPXCompat(c *reims.Client, name string, rep host.Report, cur *reims.VMDetail) {
if rep.NeedsColdRebootWorkaround || !rep.WHPXCaps.KernelIrqchipAvailable || rep.WHPXCaps.NestedVirtProperty {
return
}
if a.activeRuntimeHasPatch("nested-virt-nonfatal") {
return
}
if reims.HasKernelIrqchipArg(cur.ExtraArgs) {
return
}
+22
View File
@@ -133,3 +133,25 @@ func TestBuildUpdateOpenCoreArgs(t *testing.T) {
t.Fatalf("BuildUpdateOpenCoreArgs(false) = %q", gotOff)
}
}
func TestCreateDefaultNVMeAndPreview(t *testing.T) {
opts := CreateOpts{Name: "macos-tahoe", MacOS: "tahoe", CPUs: 8, Memory: "16G"}
if got := EffectiveCreateDiskController(opts); got != "nvme" {
t.Fatalf("EffectiveCreateDiskController default = %q, want nvme", got)
}
cmd, err := PreviewCreateCommand(opts)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(cmd, "&& reims-ctl set macos-tahoe --disk-controller nvme") {
t.Fatalf("PreviewCreateCommand missing nvme set step: %q", cmd)
}
opts.DiskController = "ahci"
cmdAhci, err := PreviewCreateCommand(opts)
if err != nil {
t.Fatal(err)
}
if strings.Contains(cmdAhci, "--disk-controller") {
t.Fatalf("PreviewCreateCommand should omit set step for ahci: %q", cmdAhci)
}
}
+25 -5
View File
@@ -87,10 +87,11 @@ type CreateOpts struct {
Installer string `json:"installer,omitempty"`
CPUs int `json:"cpus,omitempty"`
Memory string `json:"memory,omitempty"`
DiskSize string `json:"disk_size,omitempty"`
Disk string `json:"disk,omitempty"`
DiskMode string `json:"disk_mode,omitempty"`
Graphics string `json:"graphics,omitempty"`
DiskSize string `json:"disk_size,omitempty"`
Disk string `json:"disk,omitempty"`
DiskMode string `json:"disk_mode,omitempty"`
DiskController string `json:"disk_controller,omitempty"`
Graphics string `json:"graphics,omitempty"`
GPU string `json:"gpu,omitempty"`
Resolution string `json:"resolution,omitempty"`
Displays int `json:"displays,omitempty"`
@@ -181,6 +182,9 @@ func ValidateCreate(o CreateOpts, rep host.Report) []ValidationIssue {
issues = append(issues, ValidationIssue{Field: "disk", Code: "disk_not_found", Message: "Selected disk image file does not exist"})
}
}
if dc := strings.ToLower(strings.TrimSpace(o.DiskController)); dc != "" && dc != "nvme" && dc != "ahci" && dc != "virtio" {
issues = append(issues, ValidationIssue{Field: "disk_controller", Code: "invalid_disk_controller", Message: "Disk controller must be nvme, ahci, or virtio"})
}
if o.Installer != "" {
if _, err := os.Stat(o.Installer); err != nil {
issues = append(issues, ValidationIssue{Field: "installer", Code: "installer_not_found", Message: "Selected installer image file does not exist"})
@@ -313,6 +317,18 @@ func BuildCreateArgs(o CreateOpts) ([]string, error) {
return args, nil
}
// EffectiveCreateDiskController returns the disk controller to apply to a newly
// created VM. Defaults to NVMe because upstream reims-ctl confirms macOS
// Recovery, installer, and installed macOS all support NVMe natively with lower
// I/O overhead and TRIM/discard (upstream 3731afd vm.rs:188-190, qemu.rs:389-394).
func EffectiveCreateDiskController(o CreateOpts) string {
dc := strings.ToLower(strings.TrimSpace(o.DiskController))
if dc == "" {
return "nvme"
}
return dc
}
// PreviewCreateCommand formats the exact CLI command shown on Step 5 of the wizard.
func PreviewCreateCommand(o CreateOpts) (string, error) {
args, err := BuildCreateArgs(o)
@@ -328,7 +344,11 @@ func PreviewCreateCommand(o CreateOpts) (string, error) {
quoted = append(quoted, a)
}
}
return strings.Join(quoted, " "), nil
cmd := strings.Join(quoted, " ")
if dc := EffectiveCreateDiskController(o); dc != "ahci" {
cmd += fmt.Sprintf(" && reims-ctl set %s --disk-controller %s", o.Name, dc)
}
return cmd, nil
}
// BuildSetArgs converts SetOpts into reims-ctl set CLI arguments.
+32 -2
View File
@@ -15,6 +15,23 @@ type Optimization struct {
Detail string `json:"detail,omitempty"`
}
// CanSafelyPinPCores reports whether pinning a QEMU process with vmCPUs vCPUs
// exclusively to the host's P-cores is safe without oversubscribing logical
// CPUs. On non-SMT hybrid CPUs such as Intel Core Ultra 200 (Arrow Lake, e.g.
// 6P/6T + 8E), pinning an 8-vCPU VM onto 6 logical CPUs causes XNU spinlock
// lock-holder preemption stalls. Requires at least vmCPUs+1 P-core logical CPUs
// so QEMU I/O and vGPU threads have headroom alongside the vCPUs.
func CanSafelyPinPCores(rep Report, vmCPUs int) (bool, int) {
pThreads := len(rep.PCoreLogicalCPUs)
if pThreads == 0 {
pThreads = rep.PCoreCount
}
if !rep.HasHybridCores || rep.PCoreMask == 0 || pThreads <= 0 || vmCPUs <= 0 {
return false, pThreads
}
return pThreads >= vmCPUs+1, pThreads
}
// EvaluateOptimizations combines host capability probes with the active
// runtime's patch list so the UI can show accurate, self-explanatory guidance
// for every optimization toggle without guessing.
@@ -32,12 +49,16 @@ func EvaluateOptimizations(rep Report, runtimePatches []string) []Optimization {
// 1. P-Core affinity pinning (hybrid Intel CPUs)
if rep.HasHybridCores {
detail := fmt.Sprintf("%dP+%dE", rep.PCoreCount, rep.ECoreCount)
if len(rep.PCoreLogicalCPUs) > 0 {
detail = fmt.Sprintf("%dP(%dT)+%dE", rep.PCoreCount, len(rep.PCoreLogicalCPUs), rep.ECoreCount)
}
out = append(out, Optimization{
ID: "pcore_pin",
Status: "recommended",
Supported: true,
Recommended: true,
Detail: fmt.Sprintf("%dP+%dE", rep.PCoreCount, rep.ECoreCount),
Detail: detail,
})
} else {
out = append(out, Optimization{
@@ -57,7 +78,8 @@ func EvaluateOptimizations(rep Report, runtimePatches []string) []Optimization {
})
case !rep.NeedsColdRebootWorkaround:
// Windows 11 / Server 2022+: QEMU enables kernel-irqchip by default,
// unless NestedVirtualization property probe fails (e.g. hr=0x80370302).
// unless NestedVirtualization property probe fails (e.g. hr=0x80370302)
// on an unpatched runtime.
if rep.WHPXCaps.NestedVirtProperty {
out = append(out, Optimization{
ID: "kernel_irqchip",
@@ -65,6 +87,14 @@ func EvaluateOptimizations(rep Report, runtimePatches []string) []Optimization {
Supported: true,
Recommended: true,
})
} else if hasPatch("nested-virt-nonfatal") {
out = append(out, Optimization{
ID: "kernel_irqchip",
Status: "recommended",
Supported: true,
Recommended: true,
Detail: "win11-nested-virt-nonfatal",
})
} else {
out = append(out, Optimization{
ID: "kernel_irqchip",
+41
View File
@@ -64,6 +64,12 @@ func TestEvaluateOptimizationsWin10AndWin11(t *testing.T) {
t.Fatalf("win11 cold_reboot = %+v", o)
}
// Win11 with nested-virt-nonfatal patch -> kernel_irqchip recommended even when probe returns 0x80370302.
opts11Patched := EvaluateOptimizations(win11BrokenNested, []string{"qemu-whpx-nested-virt-nonfatal.patch"})
if o := findOpt(t, opts11Patched, "kernel_irqchip"); o.Status != "recommended" || !o.Supported {
t.Fatalf("win11 with nested-virt-nonfatal patch = %+v", o)
}
// Win11 with full support.
win11BrokenNested.WHPXCaps.NestedVirtProperty = true
win11BrokenNested.WHPXCaps.NestedVirtProbeError = ""
@@ -72,3 +78,38 @@ func TestEvaluateOptimizationsWin10AndWin11(t *testing.T) {
t.Fatalf("win11 full support = %+v", o)
}
}
func TestCanSafelyPinPCores(t *testing.T) {
// Arrow Lake Core Ultra 9 285H: 6 P-cores with NO Hyper-Threading (6 logical CPUs).
arrowLake := Report{
HasHybridCores: true,
PCoreCount: 6,
ECoreCount: 10,
PCoreMask: 0x3C03,
PCoreLogicalCPUs: []int{0, 1, 10, 11, 12, 13},
}
if ok, threads := CanSafelyPinPCores(arrowLake, 8); ok || threads != 6 {
t.Fatalf("arrowLake 8 vCPU: got (%v, %d), want (false, 6)", ok, threads)
}
if ok, threads := CanSafelyPinPCores(arrowLake, 6); ok || threads != 6 {
t.Fatalf("arrowLake 6 vCPU: got (%v, %d), want (false, 6)", ok, threads)
}
if ok, threads := CanSafelyPinPCores(arrowLake, 4); !ok || threads != 6 {
t.Fatalf("arrowLake 4 vCPU: got (%v, %d), want (true, 6)", ok, threads)
}
// Raptor Lake 6P with Hyper-Threading (12 logical CPUs).
raptorLake := Report{
HasHybridCores: true,
PCoreCount: 6,
ECoreCount: 8,
PCoreMask: 0xFFF,
PCoreLogicalCPUs: []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
}
if ok, threads := CanSafelyPinPCores(raptorLake, 8); !ok || threads != 12 {
t.Fatalf("raptorLake 8 vCPU: got (%v, %d), want (true, 12)", ok, threads)
}
if ok, threads := CanSafelyPinPCores(raptorLake, 12); ok || threads != 12 {
t.Fatalf("raptorLake 12 vCPU: got (%v, %d), want (false, 12)", ok, threads)
}
}
+1
View File
@@ -13,3 +13,4 @@
| `reims-vgpu-cargo-lock.patch` | `steelbrain/reims-vgpu` (`3731afd`) 的 `Cargo.lock` | 不改代码:cargo 构建时给 `metal2vulkan`、`metal2vulkan-air`、`metal2vulkan-runtime` 三个包补上了 `source = "git+…metal2vulkan?rev=0b0ac58…"`。为了让源码包和实际构建逐字节一致,照实声明(2026-11-28 从本机构建目录 `git diff` 取得) | 不需要上游修复;上游 `Cargo.lock` 补齐后即可删除 |
| `qemu-whpx-win10-compat.patch` | `steelbrain/qemu-reims-vgpu` (`4571bc5`) | 修复 Windows 10 19045 上 WHPX 两处必现崩溃:① `whpx_tsc_deadline_refused()` 在正式 partition 上删建 vCPU 0 导致 `WHvCreateVirtualProcessor` 返回 `0x80070057`;② `whpx_set_registers()` 调用 Win11 新增的 `WHvResetPartition` 未判空导致 `0xc0000005` 崩溃 | 待提交上游 PR |
| `qemu-whpx-win10-startup-ipis.patch` | 同上,须在前一项之后应用 | Win10 开启内核 irqchip 时,将多核客体的 INIT/SIPI 经 `WHvRequestInterrupt` 转发,避免 XNU 启动从核时停住。8 核两次冷启动与 12 核冷启动均验证 x2APIC、FileVault、SSH 和图形登录,默认 8 核启动与正常关机也通过。多核整体性能收益和客体冷重启仍待验证 | 待提交上游 PR |
| `qemu-whpx-nested-virt-nonfatal.patch` | 同上,须在前两项之后应用 | 部分 Windows 11 宿主(如 24H2/Home 或 Core Ultra 200)在 `WHvGetCapability` 报告 `Bank1.NestedVirtSupport=1`,但 `WHvSetPartitionProperty(NestedVirtualization)` 返回 `hr=0x80370302`(`WHV_E_UNKNOWN_PROPERTY`)。原代码将其视为致命错误直接中止启动,迫使退回 `kernel-irqchip=off`;改为 `warn_report` 并清零 `Bank1.NestedVirtSupport`,保留完整的 Hyper-V 内核态 x2APIC / SynIC 加速 | 待真机编译冒烟后提交上游 PR |
@@ -0,0 +1,25 @@
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -3525,17 +3525,16 @@
whpx_rdtsc_cap = processor_features.Bank0.RdtscpSupport;
whpx_invpcid_cap = processor_features.Bank0.InvpcidSupport;
if (whpx_irqchip_in_kernel() && processor_features.Bank1.NestedVirtSupport) {
memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
prop.NestedVirtualization = 1;
hr = whp_dispatch.WHvSetPartitionProperty(
whpx->partition,
WHvPartitionPropertyCodeNestedVirtualization,
&prop,
sizeof(WHV_PARTITION_PROPERTY));
if (FAILED(hr)) {
- error_report("WHPX: Failed to enable nested virtualization, hr=%08lx", hr);
- ret = -EINVAL;
- goto error;
+ warn_report("WHPX: Failed to enable nested virtualization, hr=%08lx; continuing without nested virt", hr);
+ processor_features.Bank1.NestedVirtSupport = 0;
}
}
/*
+11 -2
View File
@@ -364,6 +364,7 @@ func (a *App) emitStartSummary(name string, detail reims.VMDetail, rep host.Repo
case strings.Contains(lowExtra, "kernel-irqchip=on"):
irqMode = "on"
}
canPin, pThreads := host.CanSafelyPinPCores(rep, detail.CPUs)
if loc == i18n.ZhCN {
coldStr := "关闭"
if qmpAddr != "" {
@@ -371,7 +372,11 @@ func (a *App) emitStartSummary(name string, detail reims.VMDetail, rep host.Repo
}
pinStr := "关"
if pinPCores && rep.HasHybridCores {
pinStr = fmt.Sprintf("开(%dP)", rep.PCoreCount)
if canPin {
pinStr = fmt.Sprintf("开(%dP/%d线程)", rep.PCoreCount, pThreads)
} else {
pinStr = fmt.Sprintf("自动跳过(%d核≥%dP线程)", detail.CPUs, pThreads)
}
}
a.emitLog(name, fmt.Sprintf("[启动] 运行时 %s · %d 核 / %s(可用提交内存 %.1f GB)· 图形 %s · 磁盘 %s · irqchip=%s · 绑P核=%s · Win10冷重启=%s",
rtCommit, detail.CPUs, detail.Memory, rep.CommitAvailGB, detail.Graphics, strings.ToUpper(detail.DiskController), irqMode, pinStr, coldStr))
@@ -383,7 +388,11 @@ func (a *App) emitStartSummary(name string, detail reims.VMDetail, rep host.Repo
}
pinStr := "off"
if pinPCores && rep.HasHybridCores {
pinStr = fmt.Sprintf("on(%dP)", rep.PCoreCount)
if canPin {
pinStr = fmt.Sprintf("on(%dP/%dT)", rep.PCoreCount, pThreads)
} else {
pinStr = fmt.Sprintf("skipped(%dvCPU>=%dPT)", detail.CPUs, pThreads)
}
}
a.emitLog(name, fmt.Sprintf("[start] runtime %s · %d vCPU / %s (commit free %.1f GB) · graphics %s · disk %s · irqchip=%s · P-core=%s · Win10-cold-reboot=%s",
rtCommit, detail.CPUs, detail.Memory, rep.CommitAvailGB, detail.Graphics, strings.ToUpper(detail.DiskController), irqMode, pinStr, coldStr))