From nobody Sat Nov 23 18:01:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1729799042; cv=none; d=zohomail.com; s=zohoarc; b=g0/+C0bR368N6DCxsB0Uu4MGXV2dDdKPHjdgxc3JliT5NAd8ulCJS7rv0AhTwHMJ1/PHvmhLR4b9QdXF8WUFGiVvpYnaDfvT4gNrtt/81cVWlAdaR4EwDwBJTqTIeXiuBHH3YD0kkCN/Cmr6u9+SxcsSwp0rPNqb3wUGQt9j124= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729799042; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KTkxEBmFYjhTgE61q2Wuic/Pvst8IIWSyZemzZLXOhI=; b=ijF+Vv0tEzyl5puQXpK75f6r0cul4lG9Tk/XMWf+2Z9h5jhCqKoiBWpbWANXAfxMezSAD3h2MQcb8jYrlLEqABLYtUsn7SLG39Ksu8o6prgZUEfad5cZCO9OzS7h3O0dTt7kUHD9qUPcIZkebLqblezyK+tl6NCOEYjrEnJBGuo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729799042352202.49853017356247; Thu, 24 Oct 2024 12:44:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t43jr-0006MA-IA; Thu, 24 Oct 2024 15:43:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t43jn-0006Lo-VD for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:15 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t43jl-0007zv-PS for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:15 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-37d58377339so991842f8f.1 for ; Thu, 24 Oct 2024 12:43:13 -0700 (PDT) Received: from localhost.localdomain (h082218084190.host.wavenet.at. [82.218.84.190]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912d6545sm652536866b.31.2024.10.24.12.43.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 24 Oct 2024 12:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1729798992; x=1730403792; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KTkxEBmFYjhTgE61q2Wuic/Pvst8IIWSyZemzZLXOhI=; b=s4YZ3OJxjn1rKhQETOH1KKUjkNkHWgU58ieAQvU+mr2MPqmrj2mAmBR0DIg73dRXYh 1xPaROULLSLjlg4U0Mbb70iWjkXpa8KB2UTWfz0z1b6H2oP7TI32y6Tr3wWjp7smqBcy mkv/V9StMiw9/jvFKDbZDvrvFAXbDPwWy3EEh/bn6b/zc1EyyQ7vz6rPtQX5ElZjKlri R02tXlZpvD6Inmo5MgQxXvfmeW4+QAZuDGeCzA7rxSn+pl2jYuOmqY/m66T0mKHwZjjM lG/uTsboJ2siwueBBjrWctSPWkUDk5prF7Eg36dOJKjFpEigDLj03npqXPYiWT115mni vxFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729798992; x=1730403792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KTkxEBmFYjhTgE61q2Wuic/Pvst8IIWSyZemzZLXOhI=; b=GfNxJmulh3aNzbpkrJ6689+pdTLR75BFdATxawcaNra+aznqiESfOuiN8sOh0Jdrg0 Q1K1my19i5bJVUqTOVo62FtqdY5JoMx7sbXP2mDW1xteSIOsbARI7YmSc+J12eXhePlY N24r/V8PgvivMsjF2JVqabYrmE2BzJ54uWNNWIWAwjQbufKl5ndHf47rH0RUKScqux7L aRnjWRE4JhA3SBTvQk2XW8++6tPrVuAGSmU9OKuAPOVLo+XqYJ5lxQlJuer1wohpdsM1 2neLnRDUkb/sO7NMzdL3u/mY/6N05qXeapsu0ccoPpx9dE49t2JYOIV8Zj8yPIuAxeZR nfXQ== X-Gm-Message-State: AOJu0Yyc1uo0cd9CzuM85mLt3XGDPE7lZVXgy1Y7VkMF0pmLCfdGBa14 9nrMI30UnBWtCIZBNsKgIpc6amAJSzPYtnAaXPTmClT2VkSirDLTXy9HYXkZwQ+XisDf/16lbl5 ayw== X-Google-Smtp-Source: AGHT+IHRayTsrm/xDVgQ3GClezAuv3usuxaXuzfPFbr7p8hDS25sTiuC41GxBcIKLqFSOPiFzbOBkQ== X-Received: by 2002:adf:8bdd:0:b0:37c:cdbf:2cc0 with SMTP id ffacd0b85a97d-37efcf8d06cmr5662201f8f.53.1729798992157; Thu, 24 Oct 2024 12:43:12 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, Phil Dennis-Jordan Subject: [PATCH 1/4] i386/hvf: Integrates x2APIC support with hvf accel Date: Thu, 24 Oct 2024 21:43:00 +0200 Message-Id: <20241024194303.32100-2-phil@philjordan.eu> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20241024194303.32100-1-phil@philjordan.eu> References: <20241024194303.32100-1-phil@philjordan.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: neutral client-ip=2a00:1450:4864:20::435; envelope-from=phil@philjordan.eu; helo=mail-wr1-x435.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1729799044007116600 Support for x2APIC mode was recently introduced in the software emulated APIC implementation for TCG. Enabling it when using macOS=E2=80=99s hvf accelerator is useful and significantly helps performance, as Qemu currently uses the emulated APIC when running on hvf as well. This change wires up the read & write operations for the MSR VM exits and allow-lists the CPUID flag in the x86 hvf runtime. Signed-off-by: Phil Dennis-Jordan --- target/i386/hvf/x86_cpuid.c | 4 ++-- target/i386/hvf/x86_emu.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/target/i386/hvf/x86_cpuid.c b/target/i386/hvf/x86_cpuid.c index e56cd8411ba..4f260d46a81 100644 --- a/target/i386/hvf/x86_cpuid.c +++ b/target/i386/hvf/x86_cpuid.c @@ -64,8 +64,8 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t = idx, CPUID_PAT | CPUID_PSE36 | CPUID_CLFLUSH | CPUID_MMX | CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS; ecx &=3D CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSSE3 | - CPUID_EXT_FMA | CPUID_EXT_CX16 | CPUID_EXT_PCID | - CPUID_EXT_SSE41 | CPUID_EXT_SSE42 | CPUID_EXT_MOVBE | + CPUID_EXT_FMA | CPUID_EXT_CX16 | CPUID_EXT_PCID | CPUID_EXT_S= SE41 | + CPUID_EXT_SSE42 | CPUID_EXT_X2APIC | CPUID_EXT_MOVBE | CPUID_EXT_POPCNT | CPUID_EXT_AES | CPUID_EXT_XSAVE | CPUID_EXT_AVX | CPUID_EXT_F16C | CPUID_EXT_RDRAND; ecx |=3D CPUID_EXT_HYPERVISOR; diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index 38c782b8e3b..be675bcfb71 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -663,6 +663,15 @@ static void exec_lods(CPUX86State *env, struct x86_dec= ode *decode) env->eip +=3D decode->len; } =20 +static void raise_exception(CPUX86State *env, int exception_index, + int error_code) +{ + env->exception_nr =3D exception_index; + env->error_code =3D error_code; + env->has_error_code =3D true; + env->exception_injected =3D 1; +} + void simulate_rdmsr(CPUX86State *env) { X86CPU *cpu =3D env_archcpu(env); @@ -677,6 +686,17 @@ void simulate_rdmsr(CPUX86State *env) case MSR_IA32_APICBASE: val =3D cpu_get_apic_base(cpu->apic_state); break; + case MSR_APIC_START ... MSR_APIC_END: { + int ret; + int index =3D (uint32_t)env->regs[R_ECX] - MSR_APIC_START; + + ret =3D apic_msr_read(index, &val); + if (ret < 0) { + raise_exception(env, EXCP0D_GPF, 0); + } + + break; + } case MSR_IA32_UCODE_REV: val =3D cpu->ucode_rev; break; @@ -777,6 +797,17 @@ void simulate_wrmsr(CPUX86State *env) case MSR_IA32_APICBASE: cpu_set_apic_base(cpu->apic_state, data); break; + case MSR_APIC_START ... MSR_APIC_END: { + int ret; + int index =3D (uint32_t)env->regs[R_ECX] - MSR_APIC_START; + + ret =3D apic_msr_write(index, data); + if (ret < 0) { + raise_exception(env, EXCP0D_GPF, 0); + } + + break; + } case MSR_FSBASE: wvmcs(cs->accel->fd, VMCS_GUEST_FS_BASE, data); break; --=20 2.39.3 (Apple Git-145) From nobody Sat Nov 23 18:01:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1729799042; cv=none; d=zohomail.com; s=zohoarc; b=Gc3LZoXo0S877IW6dPrG4xgk0z6dSjlnYG6NqMgAC3a3bmYJVFi+OAErlb1oHY3LwDc3veucSHPAcZFTnSvaqG33qonF3cKlLwznjQeod21Y4yp2Wxk6V+sscWEZb4pDCD7EVUYDovtHIT+KC84pIODRtIS4PWVOgN76wPe02xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729799042; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ULV6js8+Kl+ICVkJYfpF5H1/0wNopvSfTu+wRnziPlo=; b=jWcPhecshoO7xio7vvBOxoduYa6mxuZtzPxfs8q24gxZ+1C/gZ+OfvC2O0Z9Jg1nFgaoESvnJT8hVIgaHmToYktvPAdSGdpDnlN3+tmSMg/tZVNHBa/Mak0TWf/IoRsQJ2eTjEkrzxv+SPu5W1Dju/sx1fv233p4JL4mAkwKtrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17297990420001013.8981038275518; Thu, 24 Oct 2024 12:44:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t43jy-0006NO-4F; Thu, 24 Oct 2024 15:43:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t43jp-0006M4-6x for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:17 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t43jn-00080s-Ad for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:16 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a9a16b310f5so189569766b.0 for ; Thu, 24 Oct 2024 12:43:14 -0700 (PDT) Received: from localhost.localdomain (h082218084190.host.wavenet.at. [82.218.84.190]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912d6545sm652536866b.31.2024.10.24.12.43.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 24 Oct 2024 12:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1729798993; x=1730403793; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ULV6js8+Kl+ICVkJYfpF5H1/0wNopvSfTu+wRnziPlo=; b=BM/tuZ2zzH6ejmDpBkJjs8u4mY2wew7sCFk4DbdX59EBKVo3SFkoF0uq0JB+MTkIYT EJOrbl26VQdztepBJ5bV6fQ6jWBGa/3iykLyZcLfQ0TfdH8x6qZZ0KQKW121nLHb41AZ aTWzd55U3nS95C0xLtZh5oM/qDBZ7iUCdeOJd2QdBCtAbBeNQmdzMCEx8gjSJshkkIt5 CiZyaOp+OXdi7B4o9K+hwrBaq4bEuAZS1KJ6cvFHpYHsFqRY2LvLFxoIvgvRboerxGg8 aS0jR6p3u7VnLxQyyzfcGp1hi8fHrc5ba2ydOXUmMfkpJAXgdtoROHXxaOEfqcu1U9ZE +4Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729798993; x=1730403793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ULV6js8+Kl+ICVkJYfpF5H1/0wNopvSfTu+wRnziPlo=; b=jlBl4Ci8Lklj7vjIqv1j8dD945A1useUofXmbGv3h0LVVUQrhjnbLZmEzXwodBsRNS LdaOPHWEjg94HasH7vIs5J8CaKw35S+/UAyAeDqpTRAPlZMQrbGARX69a8Trx3gSzzGC wLL+i7tkpUTh7H0dABke+DhM5h5dZDtkDmrkqLc0V1W4KXH4vgq7Y4Mu4cBDQgylqgRR KdbaJ2t9RK/2+qr/9yAiLLIOAyzvY+YczKM7HZMhi4buMu4vuEDyHLCd3954lboMHPaP Nqvjtb4N9XWRz+73lmAmPFjr7y7l9SUBNJSqVajB/u9J2HNunvrPMIRAZs5Ft7JueMtM YFcQ== X-Gm-Message-State: AOJu0Ywmn4GJy9GY+j/9IzFMer32JHRgYiTUtzAfdkjjbgj/QiymSEEz ovJXMiBeES/nO6WRrRKjNB/XCXkO/vVNyVSXKFu/tSGP7gQO86K6mIT1I06oKQLAAj1wCqLQtj5 pYA== X-Google-Smtp-Source: AGHT+IEj5AGylXBG5arNrL973HtKj+0OGlzvBxsNQbMQsIzmhG1GYNPDl8FTZr2cY+/4PV+cHKiagA== X-Received: by 2002:a17:907:7294:b0:a99:4d67:eac1 with SMTP id a640c23a62f3a-a9abf96eb78mr679419866b.52.1729798993426; Thu, 24 Oct 2024 12:43:13 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, Phil Dennis-Jordan Subject: [PATCH 2/4] i386/hvf: Fixes startup memory leak (vmcs caps) Date: Thu, 24 Oct 2024 21:43:01 +0200 Message-Id: <20241024194303.32100-3-phil@philjordan.eu> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20241024194303.32100-1-phil@philjordan.eu> References: <20241024194303.32100-1-phil@philjordan.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: neutral client-ip=2a00:1450:4864:20::62b; envelope-from=phil@philjordan.eu; helo=mail-ej1-x62b.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1729799044015116600 Content-Type: text/plain; charset="utf-8" The hvf_caps data structure only exists once as part of the hvf accelerator state, but it is initialised during vCPU initialisation. This change theref= ore adds a check to ensure memory for it is only allocated once. Signed-off-by: Phil Dennis-Jordan --- target/i386/hvf/hvf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 68dc5d9cf75..8527bce6eef 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -239,7 +239,9 @@ int hvf_arch_init_vcpu(CPUState *cpu) init_emu(); init_decoder(); =20 - hvf_state->hvf_caps =3D g_new0(struct hvf_vcpu_caps, 1); + if (hvf_state->hvf_caps =3D=3D NULL) { + hvf_state->hvf_caps =3D g_new0(struct hvf_vcpu_caps, 1); + } env->hvf_mmio_buf =3D g_new(char, 4096); =20 if (x86cpu->vmware_cpuid_freq) { --=20 2.39.3 (Apple Git-145) From nobody Sat Nov 23 18:01:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1729799063; cv=none; d=zohomail.com; s=zohoarc; b=RcA7OZNbuHmYRUaScLuuZHbcFAVPQc/MvbbOc9xQSnhUrP9JB0AAQZ5GU9Agm2n36D7crvuUJAqe8kVakgotbCgaUbJA/aFUkVEg03+xsYU0LIWVkRqVUx4/gAPg0FHV/do8YkIdRD+8jWpqHwJHMJxZsnbM6o+SsmsKTDi5loE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729799063; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DQg34qAwXV1dkoltfasHGRhCwLkvl9EuX77LcykV+9c=; b=HCznYHtzDhI6FH78RlTmu0tzO2XC2Qi/1+F7F0Hhyls2aenyQyQRFNu7D1S52ErieSnAIDCMKwYU5QdqCP+aHxJmdd3fdlVv1X/DdjqzqcurwwRftQBwHdk3NF9nhbpxgXLQDlGY2g4NXl1cOpAio8gk5ZLRmUGuawXvGNgb+ew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729799063966156.63049003696517; Thu, 24 Oct 2024 12:44:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t43k3-0006OG-Tb; Thu, 24 Oct 2024 15:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t43jq-0006ME-Fn for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:18 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t43jo-00081D-Vl for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:18 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-539e6c754bdso1240596e87.2 for ; Thu, 24 Oct 2024 12:43:16 -0700 (PDT) Received: from localhost.localdomain (h082218084190.host.wavenet.at. [82.218.84.190]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912d6545sm652536866b.31.2024.10.24.12.43.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 24 Oct 2024 12:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1729798995; x=1730403795; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DQg34qAwXV1dkoltfasHGRhCwLkvl9EuX77LcykV+9c=; b=PD/Uw0x75AOlCgvZmnAHgZSmESOZjZFwt8MOJqrmdurAsV2DDyzddnewexiEQQQhCA NA5t44gcb6bRZG3eEyZuPWATFekeZeJ0q5HkIUbXrBLK4kkHdkO+CR80H3MPCfJ1kB+Q GpYhOWkQvumHPdv6IfKTWY3nSmlvuargfQrnvNxkkHWv4/SW+xmRsuJ9qkpp2mRtws7t SssufmJxbNRkiXXJut34+PVGtOZhoRFcAQ2l8ebgjTW8IZvj8SVxqq0vc+KRx9lUpnz8 3OUGHYls2c7OwbBpD1CIVV5AB7i+sLaPppbfKP9r/dtlUUlx6Pj3CpaWUR6DqVXfKZnR KoVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729798995; x=1730403795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DQg34qAwXV1dkoltfasHGRhCwLkvl9EuX77LcykV+9c=; b=HltpY2SYrtFcCOBZX/a3dl8QiKtPlIFsda43rgbwNKAW48eXqtRFIjH5F2IOPPy+dJ JCM49xu0ChTk7LTd2xe+EaGyuQDU+kZHIWU1eg5fy814eQkfwM0jYTgE7wj23Dio+R+R kXjH6yo8r7gsuzXUNZB+Nl/wmFbCYjXXEI7V8p6xyUuKfMYLlo3Sl4tQK9WtUDTbwKBC gzOXZpVxWPGcobDUV7L+wq6HXf0nu4kM7N5rkO7fLNJ0tW3qpB798trECYyUyF/jMrix U8e3IyasxovW16+1rjM+CF2WYOvQNlCRDnUC8m41ae4S05dtHbjv6l73rQUmIUrlffFs 8uxA== X-Gm-Message-State: AOJu0Yw0UBMEOtY9nOBILOb6cY/YfAMHKtkhG49Io0VexhrEtDTxUcM8 AtvT0+wmtlJZ0Ke1S3MSoJK5WmNOu8U4lPBjquKbcKP2nF23zCBzLmrfLd1Y8VWud7Z25l0kbwl ufg== X-Google-Smtp-Source: AGHT+IFa/c5x5Y4RpZADd72eqSIkPb0kJta9ubAFoaeky0eYE0NG+YFmMmwui8HaOrH5lLLZpt8d5w== X-Received: by 2002:a05:6512:3510:b0:53b:1fc6:3cf4 with SMTP id 2adb3069b0e04-53b1fc64039mr2620513e87.41.1729798994732; Thu, 24 Oct 2024 12:43:14 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, Phil Dennis-Jordan Subject: [PATCH 3/4] i386/hvf: Raise exception on error setting APICBASE Date: Thu, 24 Oct 2024 21:43:02 +0200 Message-Id: <20241024194303.32100-4-phil@philjordan.eu> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20241024194303.32100-1-phil@philjordan.eu> References: <20241024194303.32100-1-phil@philjordan.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: neutral client-ip=2a00:1450:4864:20::133; envelope-from=phil@philjordan.eu; helo=mail-lf1-x133.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1729799065376116600 Content-Type: text/plain; charset="utf-8" When setting the APICBASE MSR to an illegal value, the APIC implementation will return an error. This change forwards that report to the guest as an exception rather than ignoring it when using the hvf accelerator. Signed-off-by: Phil Dennis-Jordan --- target/i386/hvf/x86_emu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index be675bcfb71..015f760acb3 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -794,9 +794,16 @@ void simulate_wrmsr(CPUX86State *env) switch (msr) { case MSR_IA32_TSC: break; - case MSR_IA32_APICBASE: - cpu_set_apic_base(cpu->apic_state, data); + case MSR_IA32_APICBASE: { + int r; + + r =3D cpu_set_apic_base(cpu->apic_state, data); + if (r < 0) { + raise_exception(env, EXCP0D_GPF, 0); + } + break; + } case MSR_APIC_START ... MSR_APIC_END: { int ret; int index =3D (uint32_t)env->regs[R_ECX] - MSR_APIC_START; --=20 2.39.3 (Apple Git-145) From nobody Sat Nov 23 18:01:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1729799042; cv=none; d=zohomail.com; s=zohoarc; b=WilR7qxlHvX+qMr0mVK/HWUopX3MU09Iv07xd4jmUwlxR6eZWNkz0tbuV225bS/o9TjXb27H9xzeRRlBUkTpw8K1y8kT8L68JiV/tvjTU51Rdxh7tNQL/xtP+KkNw908CDNubjjW8p6BNWzzqks+28yPkn5xSxXzs3sHpPeUVDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729799042; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DQ/wvxuTvQaiavS01m+IKLgZecmKu0OzwEWLUO9nnOE=; b=f/ia6grVBw9IRzOA9Sk843k6NcacKZGHYRpCXmzzUGCM5limAwVw3vsOTSGzcO4DKUtpoKfFKX8dtB0pdF9Fp4kf5ViBlGty8My3P7OpkTzTLbrpnHgrPqSySiKjKhXu76PV1PUha30V5kjTLyT5NyConadJMFtWPr1lOMhjb7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729799042221956.3520230803948; Thu, 24 Oct 2024 12:44:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t43k9-0006Oh-BZ; Thu, 24 Oct 2024 15:43:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t43jr-0006MW-1O for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:19 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t43jp-00081s-Dp for qemu-devel@nongnu.org; Thu, 24 Oct 2024 15:43:18 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2fb51e00c05so20397031fa.0 for ; Thu, 24 Oct 2024 12:43:17 -0700 (PDT) Received: from localhost.localdomain (h082218084190.host.wavenet.at. [82.218.84.190]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912d6545sm652536866b.31.2024.10.24.12.43.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 24 Oct 2024 12:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1729798996; x=1730403796; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DQ/wvxuTvQaiavS01m+IKLgZecmKu0OzwEWLUO9nnOE=; b=QC0qOy/QbhKv/rtQKfJjK1pbuAHOb2WBwwAMY7b/Eef4PvKIT3KaFbDDA8EV2mObja NCd58jmuCfwCA+eyg5cvr2eiOp3ejEZ+jc4EShc6UYdah1LVlH7MbaWp5rzC+2otiVvO BfBmitCt2rdMQrHXvnN2Q+JW9Kpp3b8fhIR1IQlauqHrPfyFLeURfclbbwsYmLbJW+UV o6GHokSA8sNBXkAvy13z1Qgx8fRvzCd3j3XQUbFD/6HRfcNXvc0bDbqkY86natcoV5yJ t3yooTzt+TvURIJI/22eky/LFuN8bmL/pnwB1nk67oDPXb2nBhUeteO42xVEnAUW9wqB s4jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729798996; x=1730403796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DQ/wvxuTvQaiavS01m+IKLgZecmKu0OzwEWLUO9nnOE=; b=hRc/ys6hcSBUm5Bxwbbn+Mqczs3+Pr134XOq5Ezp0slZQ1+AfVEzeX78UKJfG4CbyD O3O4blVRHjmsHQe/oI9r841HSc0J2LtiSksO6oSCyEFr1TIN3qYO4FUYYUtmVXWfwsUf 6IJL87DSYdZdSNJBw3hEESKtA7W2Dcma+nhOECtC/BGbRaj3SbjBdJgtbVM/KpeX8Mi7 7DxUFoeqKNNhBGjTvbG2UJoespRC9suHeBBUqEqvSESRWz9ngMMltQrK5jFBxLMg405d L6vgCp9oUdCWhbubf3jUqNckySEo5O5O9UkC9tc74nCdrvvMLhX1ydURezakZvWJ1Ed6 YC/w== X-Gm-Message-State: AOJu0YzkbKlSSlvm1RmWq652xDXFfNvcsVjJn9i9pyddNXn+Ch6vcpDV ZCN6PN5kvW1KxBcIxcu3STxvyeHQQEflKG4wj0D0LWqHEjr8HMouezso/G9jp9W5wymKZtJrA21 OsA== X-Google-Smtp-Source: AGHT+IErPCr1lx2PKut7PFBXRgnYuP3JhIurv8PkEvGIdyWlUCU16/GfguBhyg5L41TSSwR7lLEADA== X-Received: by 2002:a2e:b8c5:0:b0:2fb:3960:9671 with SMTP id 38308e7fff4ca-2fc9d31a99bmr70046091fa.15.1729798995571; Thu, 24 Oct 2024 12:43:15 -0700 (PDT) From: Phil Dennis-Jordan To: qemu-devel@nongnu.org Cc: dirty@apple.com, rbolshakov@ddn.com, Phil Dennis-Jordan Subject: [PATCH 4/4] i386/hvf: Removes duplicate/shadowed variables in hvf_vcpu_exec Date: Thu, 24 Oct 2024 21:43:03 +0200 Message-Id: <20241024194303.32100-5-phil@philjordan.eu> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20241024194303.32100-1-phil@philjordan.eu> References: <20241024194303.32100-1-phil@philjordan.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: neutral client-ip=2a00:1450:4864:20::233; envelope-from=phil@philjordan.eu; helo=mail-lj1-x233.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1729799043998116600 Content-Type: text/plain; charset="utf-8" Pointers to the x86 CPU state already exist at the function scope, no need to re-obtain them in individual exit reason cases. Signed-off-by: Phil Dennis-Jordan --- target/i386/hvf/hvf.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 8527bce6eef..c5d025d5576 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -586,8 +586,6 @@ int hvf_vcpu_exec(CPUState *cpu) break; } case EXIT_REASON_XSETBV: { - X86CPU *x86_cpu =3D X86_CPU(cpu); - CPUX86State *env =3D &x86_cpu->env; uint32_t eax =3D (uint32_t)rreg(cpu->accel->fd, HV_X86_RAX); uint32_t ecx =3D (uint32_t)rreg(cpu->accel->fd, HV_X86_RCX); uint32_t edx =3D (uint32_t)rreg(cpu->accel->fd, HV_X86_RDX); @@ -644,7 +642,6 @@ int hvf_vcpu_exec(CPUState *cpu) break; } case 8: { - X86CPU *x86_cpu =3D X86_CPU(cpu); if (exit_qual & 0x10) { RRX(env, reg) =3D cpu_get_apic_tpr(x86_cpu->apic_state= ); } else { --=20 2.39.3 (Apple Git-145)