From patchwork Wed Jun 28 15:52:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 697243 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4422219wrm; Wed, 28 Jun 2023 08:55:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Q9+cUZ8Kmh0MINjctEi9N1qR8MyY/qsSpJlQW91JDGlfc19aOa0I0KJP1IM9DQmuXp5CP X-Received: by 2002:a05:6214:20aa:b0:5e9:2bad:c8fa with SMTP id 10-20020a05621420aa00b005e92badc8famr38922311qvd.33.1687967707384; Wed, 28 Jun 2023 08:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687967707; cv=none; d=google.com; s=arc-20160816; b=0GaC6P6XsRFphuFiDzdPBMUnvUaaUlrFUSeAsrE5Hqbm2JVnIKHw2eGo7pYP4nsN6G V4lVA5cd7CZ5kDYU/PTsWOTCpmYVkDxysA4RsUVXp7rojS2P7Uw97SehQjtX75D/Wqqb 2ezwKyK3xr2cWWs7TQHpUPmd3j0IB00AyMhD+dVhlaXoFt00pm1LfuHPxuAyZ77qXUEV /cHRyCYHKzndx+2pDPQUEuY3KO0EZGDebkyeYM+uke+2dMv5v9pEejwYcK9PWsy3Px2r Jg/zH4AvZ0GLlE0uUxCxTyedyhPI/dM8ufA4dClW2RJTbdBSK54yrdBCL4ATN9yeMvtZ GZJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6Wo3t2aNUogBEHU7MxAIMxFu0KW7G37E7pivQuYTTOw=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=MyzF9fEuqNbP//Rup5NNDcJVCcnNrCG7+BZKlvwiffd6sJp49ZOrFSXfxo0Ja/FZfg WZPc/8pv0QeaIgYyWwKGNN6igvaAD+vHR7JmbanbMth+qrMdjnkSHj124O03TxgdmRNh 3bMjxNXJoUnldCp47HZNEtrzhT6shE93In6CHylTFFviPLOtC+Td1B4GSNOWM3IOIrVP UNA2BzOA12uxZfSCB1BOf/U/pTZj++8mudjEehMv+TIZhLbhoiF0k+EJtx2qcUFzZ+Rq AWN3pPzKqLtkx+icderZ7NhJ5bsx4O8xVXJjPd+MVt6ztgJ5nZowYMGWWZJAsG6baYwi 5NqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="si4g/rE4"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m15-20020a05620a24cf00b00765a78de87bsi3886483qkn.550.2023.06.28.08.55.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Jun 2023 08:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="si4g/rE4"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEXVU-00012C-JX; Wed, 28 Jun 2023 11:55:00 -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 1qEXVK-0000p1-Ci for qemu-devel@nongnu.org; Wed, 28 Jun 2023 11:54:50 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEXVI-0000hn-Na for qemu-devel@nongnu.org; Wed, 28 Jun 2023 11:54:50 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3128fcd58f3so6779932f8f.1 for ; Wed, 28 Jun 2023 08:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687967687; x=1690559687; 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=6Wo3t2aNUogBEHU7MxAIMxFu0KW7G37E7pivQuYTTOw=; b=si4g/rE4o+FiHprr/TuXF4pYmW5pMV4mKgrNSJh8YqEXVIvCqB3OWQYUOob/rgX2lT CMREOZDrTHXDLs8owT06eofStk3twohPFvV2cwHtEHnaxJ+Ea3CUaLo0wiWVCqDnbnvI lmV0Cq1rWu1NYqwHpGOQbrtXWZ53fyM9pkRnwft4gLeVliD6RmeaFwqYQZ1hI+32Xd1g cG9Y/BnA0uuEpgR4kko2Ur7ax3+yRVvWmh44UBDQhMFT2SHtrND4nrBgyYWIAEmojJ9I smHL29vTxFKSNSQSzqWZnYDvEVeF0yi06ddrBqdt43ANTdyp0/dKMSM4YeoadN3JMQId mInQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687967687; x=1690559687; 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=6Wo3t2aNUogBEHU7MxAIMxFu0KW7G37E7pivQuYTTOw=; b=dXG91A+UQ+CfnT4asEiKTwa+GVwczhqjJ5Ho8xXYnd3Y3qJylVz7ea9Eeif04NgCnJ /GEAI1kZHQa+ptF07ZiWHISKOULiSZtg7vhGJUM46ZMR05SCykVsx1VDaLaxHm6OBQy0 9YtHe3ojsLbkbyEccqBX4hV2Gh0hV3vFpLO5h2A3aM388UncaXBIy0UgmFDyUTcE9njV ypEwd0kQzQtCEjS7g90rHqlHX/AttrIH3XzoIWXfSOCuif0/zvDp2lTL9vPV+yf/Rpbr pLirRpxUl6fdXTvV1vLfJSb5Cq+Ss7r7ftfF1nzwEdxnVHbE2VbLHhv+hdYfV5P1gZQz xUGw== X-Gm-Message-State: ABy/qLYH27fxyPlDaqFbe83Pfd/gI8H6hYzmXV2RHnoM8FqLp48QD2sD bC3YAR+B80GHnxn8TTalU3VOlCVCwPf8CmWoN3g= X-Received: by 2002:adf:f548:0:b0:314:11f3:ca94 with SMTP id j8-20020adff548000000b0031411f3ca94mr467110wrp.41.1687967687081; Wed, 28 Jun 2023 08:54:47 -0700 (PDT) Received: from m1x-phil.lan ([176.187.207.229]) by smtp.gmail.com with ESMTPSA id cs5-20020a056000088500b0030ab5ebefa8sm13684336wrb.46.2023.06.28.08.54.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 28 Jun 2023 08:54:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 16/30] accel: Inline WHPX get_whpx_vcpu() Date: Wed, 28 Jun 2023 17:52:59 +0200 Message-Id: <20230628155313.71594-17-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230628155313.71594-1-philmd@linaro.org> References: <20230628155313.71594-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org No need for this helper to access the CPUState::accel field. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230624174121.11508-15-philmd@linaro.org> --- target/i386/whpx/whpx-all.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 185f2a2820..9ee04ee650 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -256,15 +256,6 @@ static bool whpx_has_xsave(void) return whpx_xsave_cap.XsaveSupport; } -/* - * VP support - */ - -static AccelCPUState *get_whpx_vcpu(CPUState *cpu) -{ - return (AccelCPUState *)cpu->accel; -} - static WHV_X64_SEGMENT_REGISTER whpx_seg_q2h(const SegmentCache *qs, int v86, int r86) { @@ -390,7 +381,7 @@ static uint64_t whpx_cr8_to_apic_tpr(uint64_t cr8) static void whpx_set_registers(CPUState *cpu, int level) { struct whpx_state *whpx = &whpx_global; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; CPUX86State *env = cpu->env_ptr; X86CPU *x86_cpu = X86_CPU(cpu); struct whpx_register_set vcxt; @@ -609,7 +600,7 @@ static void whpx_get_xcrs(CPUState *cpu) static void whpx_get_registers(CPUState *cpu) { struct whpx_state *whpx = &whpx_global; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; CPUX86State *env = cpu->env_ptr; X86CPU *x86_cpu = X86_CPU(cpu); struct whpx_register_set vcxt; @@ -892,7 +883,7 @@ static const WHV_EMULATOR_CALLBACKS whpx_emu_callbacks = { static int whpx_handle_mmio(CPUState *cpu, WHV_MEMORY_ACCESS_CONTEXT *ctx) { HRESULT hr; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; WHV_EMULATOR_STATUS emu_status; hr = whp_dispatch.WHvEmulatorTryMmioEmulation( @@ -917,7 +908,7 @@ static int whpx_handle_portio(CPUState *cpu, WHV_X64_IO_PORT_ACCESS_CONTEXT *ctx) { HRESULT hr; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; WHV_EMULATOR_STATUS emu_status; hr = whp_dispatch.WHvEmulatorTryIoEmulation( @@ -1417,7 +1408,7 @@ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid) * of QEMU, nor this port by calling WHvSetVirtualProcessorRegisters(). * This is the most common case. */ - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; return vcpu->exit_ctx.VpContext.Rip; } else { /* @@ -1468,7 +1459,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) { HRESULT hr; struct whpx_state *whpx = &whpx_global; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; CPUX86State *env = cpu->env_ptr; X86CPU *x86_cpu = X86_CPU(cpu); int irq; @@ -1590,7 +1581,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) static void whpx_vcpu_post_run(CPUState *cpu) { - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; CPUX86State *env = cpu->env_ptr; X86CPU *x86_cpu = X86_CPU(cpu); @@ -1617,7 +1608,7 @@ static void whpx_vcpu_process_async_events(CPUState *cpu) { CPUX86State *env = cpu->env_ptr; X86CPU *x86_cpu = X86_CPU(cpu); - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; if ((cpu->interrupt_request & CPU_INTERRUPT_INIT) && !(env->hflags & HF_SMM_MASK)) { @@ -1656,7 +1647,7 @@ static int whpx_vcpu_run(CPUState *cpu) { HRESULT hr; struct whpx_state *whpx = &whpx_global; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; struct whpx_breakpoint *stepped_over_bp = NULL; WhpxStepMode exclusive_step_mode = WHPX_STEP_NONE; int ret; @@ -2290,7 +2281,7 @@ int whpx_vcpu_exec(CPUState *cpu) void whpx_destroy_vcpu(CPUState *cpu) { struct whpx_state *whpx = &whpx_global; - AccelCPUState *vcpu = get_whpx_vcpu(cpu); + AccelCPUState *vcpu = cpu->accel; whp_dispatch.WHvDeleteVirtualProcessor(whpx->partition, cpu->cpu_index); whp_dispatch.WHvEmulatorDestroyEmulator(vcpu->emulator);