From patchwork Wed Apr 24 17:45:04 2024 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: 791528 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp965175wrq; Wed, 24 Apr 2024 10:45:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXEaMr/Ohi9w1g4Pnt+8tNwS5EL3qAKOmz8r+JemGGjkBL1szgOlnE6eTt6tpEeIyKESQF3WRsxeuxqzLLhIezR X-Google-Smtp-Source: AGHT+IFPwr74yCoxd0813mYaIRVp7wVUmbhyHFWGOy8isuSYg4pkoPd9av678rm/gSENpzCSWW80 X-Received: by 2002:a05:6214:304:b0:6a0:619e:9efc with SMTP id i4-20020a056214030400b006a0619e9efcmr3335220qvu.53.1713980754016; Wed, 24 Apr 2024 10:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713980753; cv=none; d=google.com; s=arc-20160816; b=HFfFrgbUZThGc6xsAfpIV7P0V28xK5i48Ez3ZWiQC7b6uqzBSQXzIq2hLvzkIP3Wzm GaRJOktWpCJbwETVOpUNWCyQo/C/m77gbzEu4DSVHpHltt0+b+hu7SXsvFNIuFGFd2sO QRxpZJOSrJnIUj7IO7V/kgkvaBY5JJizb+YbbPhYXVdOuzlV5U4xRxHdF+q2zhb/eYtA gDvsAIXOolRZjlEKqFZAVoX9QhDuBYDsDX7cV2kJ3V6PVuw1mEvVWPz3QMMq3OeV1TGX FmMqXw1G/OIdzHXa1jSjZJHXdieynHw35V41Z2+tAsFvoWXDsfCmG8YAOghMKP6yZxOf 5yRQ== 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=ffMjM79d07wntpDOb5AXkdSL7inATxjs1KjISEI2gk0=; fh=cxz8nMap0jiqldc4p67rXc4XZepDJBIKRl1YE8QD7uw=; b=T8Kd6VuK9ZgBf4qnQtz1RTzGJrvq2QB8PulLz8XJ4EuLM7+bYAIyf6bK0zqLfpGlTb s4skM7cBoecoF7DwejyKX1rrWDFP/f1lRsYtm7IGvn2NEpmQuzYZDpzDrIcpmNbS/AHs zJ3ArYkTb/Eu0WpxrT7RqbfGh7huJVX8vBlP8SzNlsk+TK0pe0/7wCDBzx61ojiiRwaX XAjzw3MlUVCton///zNVz33HCg1CWEKO8Mstlzdr/uuN2gxRvyqP9RsOSnlpALMQWV2H 20ogoLzhzR8ctfWjRtafk07J//Fp1HDdNVsqXFwwSIUFaETm8PAKN6aLAxPybuN28/pF nMuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WY2fiU1G; 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 iy14-20020a0562140f6e00b0069902184208si16091706qvb.265.2024.04.24.10.45.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 10:45:53 -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=WY2fiU1G; 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 1rzggS-0005NA-9O; Wed, 24 Apr 2024 13:45:29 -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 1rzggJ-0005ID-7a for qemu-devel@nongnu.org; Wed, 24 Apr 2024 13:45:20 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzggG-0005aI-IJ for qemu-devel@nongnu.org; Wed, 24 Apr 2024 13:45:17 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-41b21ed19f5so735275e9.2 for ; Wed, 24 Apr 2024 10:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713980714; x=1714585514; 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=ffMjM79d07wntpDOb5AXkdSL7inATxjs1KjISEI2gk0=; b=WY2fiU1Gq9sVpZTr+OknAg6ndnCEak4gpIrUBLHJYveYu8iUVtRh3MqNvwHU2NObnE 5I85uiAI1l4ga3JOBFafaIrJnfY/RzqaqZKI6JmKWH3it0mDJgT22yJ9WX0n04N1VYD8 SCE25QPhTOW1/MOb1mRijXVkZJc1PUmhlPiSoDHY0d7ESM42mgwZaQ+WeVd2VBh0B5L/ PmRo0Oh4wWMwLPTwtM2APr1pXXBLlezyFKtYF0HXOrlDAf4XJA6SNuDKOPpe7xTa9AHd 82A/csHqPPaza7LRcw+GcUJX4folRBTQLq4cakiEFaO5q0adY2wL5ApWIKmw3gvKIq0G CpbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713980714; x=1714585514; 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=ffMjM79d07wntpDOb5AXkdSL7inATxjs1KjISEI2gk0=; b=lvLgW9q03PEQRxpmVQqfD1z4YxsOVFcdQqE7nTNDDV1WzeYNc0OkdyBw2OggUvxnkL cYuVF7BTVUyI+t1/Aid1FAGPRDYGEwQSaBIdaX2crj5gVdrJXE+Lbm+YCvHJ+AxpMYZQ X6h2T4LgQUKbat3cQgmE7Wi+fCmGk1zQzVY5VL7az43HefpBfy3VzHfAeiapFt6Wg0uP RPPmpb3Xkcv4abE5lPqvAGE752TjFHyD5UhFYtWQMqL3HAKpK7zaetrwCm8O0NfU6gUO QssKzJx0qCvKjGfqCz4ZDwWdiM2aPs0HC7bpX+5spQiUEnbJ1YEhmCruSATFw7KI+KBl b2Iw== X-Gm-Message-State: AOJu0Yy/rorSMOWV9BnGNJxllTAcJ3c3jKdakHHqakTiImc3AKS6s0zF 7jyVC3qlMAmFJuvWD3BXtShMVosp9QaD2LH8ouGgZCBgvbkvbM0G+sBlWKvXA6QKfDEAIKbt1D2 E X-Received: by 2002:a05:600c:198b:b0:416:605b:5868 with SMTP id t11-20020a05600c198b00b00416605b5868mr2399343wmq.35.1713980714392; Wed, 24 Apr 2024 10:45:14 -0700 (PDT) Received: from localhost.localdomain (mon75-h03-176-184-51-42.dsl.sta.abo.bbox.fr. [176.184.51.42]) by smtp.gmail.com with ESMTPSA id d5-20020a5d6445000000b0034659d971a6sm17637310wrw.26.2024.04.24.10.45.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 24 Apr 2024 10:45:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil Muthuswamy , Roman Bolshakov , Alexander Graf , qemu-arm@nongnu.org, Cameron Esfahani , Reinoud Zandijk , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] accel/whpx: Use accel-specific per-vcpu @dirty field Date: Wed, 24 Apr 2024 19:45:04 +0200 Message-ID: <20240424174506.326-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240424174506.326-1-philmd@linaro.org> References: <20240424174506.326-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 autolearn=unavailable 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 WHPX has a specific use of the CPUState::vcpu_dirty field (CPUState::vcpu_dirty is not used by common code). To make this field accel-specific, add and use a new @dirty variable in the AccelCPUState structure. Signed-off-by: Philippe Mathieu-Daudé --- target/i386/whpx/whpx-all.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 31eec7048c..b08e644517 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -237,6 +237,7 @@ struct AccelCPUState { uint64_t tpr; uint64_t apic_base; bool interruption_pending; + bool dirty; /* Must be the last field as it may have a tail */ WHV_RUN_VP_EXIT_CONTEXT exit_ctx; @@ -839,7 +840,7 @@ static HRESULT CALLBACK whpx_emu_setreg_callback( * The emulator just successfully wrote the register state. We clear the * dirty state so we avoid the double write on resume of the VP. */ - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; return hr; } @@ -1394,7 +1395,7 @@ static int whpx_last_vcpu_stopping(CPUState *cpu) /* Returns the address of the next instruction that is about to be executed. */ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid) { - if (cpu->vcpu_dirty) { + if (cpu->accel->dirty) { /* The CPU registers have been modified by other parts of QEMU. */ return cpu_env(cpu)->eip; } else if (exit_context_valid) { @@ -1713,9 +1714,9 @@ static int whpx_vcpu_run(CPUState *cpu) } do { - if (cpu->vcpu_dirty) { + if (cpu->accel->dirty) { whpx_set_registers(cpu, WHPX_SET_RUNTIME_STATE); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } if (exclusive_step_mode == WHPX_STEP_NONE) { @@ -2063,9 +2064,9 @@ static int whpx_vcpu_run(CPUState *cpu) static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) { - if (!cpu->vcpu_dirty) { + if (!cpu->accel->dirty) { whpx_get_registers(cpu); - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; } } @@ -2073,20 +2074,20 @@ static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg) { whpx_set_registers(cpu, WHPX_SET_RESET_STATE); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } static void do_whpx_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg) { whpx_set_registers(cpu, WHPX_SET_FULL_STATE); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg) { - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; } /* @@ -2095,7 +2096,7 @@ static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu, void whpx_cpu_synchronize_state(CPUState *cpu) { - if (!cpu->vcpu_dirty) { + if (!cpu->accel->dirty) { run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL); } } @@ -2235,7 +2236,7 @@ int whpx_init_vcpu(CPUState *cpu) } vcpu->interruptable = true; - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; cpu->accel = vcpu; max_vcpu_index = max(max_vcpu_index, cpu->cpu_index); qemu_add_vm_change_state_handler(whpx_cpu_update_state, env); From patchwork Wed Apr 24 17:45:05 2024 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: 791531 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp965457wrq; Wed, 24 Apr 2024 10:46:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVek0No3GnN7f2m0bpLgwyhMi3YMASG012Lpjc1egCtgAoc7u5HEsvPE6ZMwe4BU8LBX7QVycEdKwXFxCALYpn6 X-Google-Smtp-Source: AGHT+IEAc8mjg8I9iKQtokk13AEoV5Y2f3ah5Hi5egsjHU9uKCjy0faJVeGK+FeD/QijYkBvXoYE X-Received: by 2002:a05:620a:a99:b0:790:890d:7bc7 with SMTP id v25-20020a05620a0a9900b00790890d7bc7mr3357661qkg.2.1713980790632; Wed, 24 Apr 2024 10:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713980790; cv=none; d=google.com; s=arc-20160816; b=v/0gAZn+ZiZbnPxxrKTebkblNx+p+krAsoVLW/POXP/bezyB1w6zq7tytYtWwt2606 YQPmLoBJAWcn1K9n1f7f7/7m+Lgu6ZzThzE3gWDq3EpG2puXV/c66ZkNMFXtQzgqEpL0 RKOKkQLzbXEFBFzigK1qdmSgWAvvalYPdwCE/IDtv37Ubik//YhszKINQIS5U3Pl7nSK DGp6c0+akNJ0ryM8eh/5yl/yOjGFJChzJF9dzgHPreSqk3u9gmfm762lONDHvxRJSuRq DNwzD0mcyGjO6h8VAlea3w2YSWSDaTp0XAq4zDGSWk1EVefhT0BzMcAl9pahy5UbrVev zmtQ== 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=nHy7p+TsVd61UoOXNyWftQk9Qj6gD334eWPgXT4ErEE=; fh=cxz8nMap0jiqldc4p67rXc4XZepDJBIKRl1YE8QD7uw=; b=a5oSQ1YnkD3iq6eI9x5RQkQn0rgugV2adq2ZcDiH+6vQE6stq0p7sMI7QIHgo0sXgb /EWsco9Wd0U3PizSwZQa1l5IEnf2WVBADJSisZDdQTCWX7DEW9tGBLJ8KfFFzcgupXvN 5rEukj6QqqW3G8bCmi2EDIGbVBlUSMbJOTFi9pWdzsgRpYs5GL9jVfVxQd5xzRr2eILf rA5fjma4ALYbZNqnQvukX/WBZGrGvdyL8YJ5bTy3CMwEj3wqR7xikvgBqpsm9ksj54zo X5jC4TlX9iWn5t5bVAt4cAfhqjjgP5yQgZuQYehRiHz7va/lsx4mAu9g9AV0/nM702gZ +4HQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HzZaFJIM; 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 o7-20020a05620a0d4700b007905c9d16desi11711952qkl.398.2024.04.24.10.46.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 10:46:30 -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=HzZaFJIM; 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 1rzggn-0005az-Vl; Wed, 24 Apr 2024 13:45:50 -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 1rzggO-0005Kl-Kg for qemu-devel@nongnu.org; Wed, 24 Apr 2024 13:45:26 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzggL-0005b4-P3 for qemu-devel@nongnu.org; Wed, 24 Apr 2024 13:45:24 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-34a3e0b31e6so51111f8f.1 for ; Wed, 24 Apr 2024 10:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713980720; x=1714585520; 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=nHy7p+TsVd61UoOXNyWftQk9Qj6gD334eWPgXT4ErEE=; b=HzZaFJIMOFG6+ofWC9QiH/vzu/10Ps+a4kASdk0uZMLuZ7Pvwf0m5OoMyW3kZ0n5GO 6AALIpb9dt50F+6mf4JohS7zgjsZJthKxZ3kOai4WuR2dCCFtlcviXE+QxgyMcYMfz6s i2T4g/5iOJvE1m7h3+gSFVLTYx/jVUjqhL+Q8qIcY/B0Kwb9UnQCpbHKqgUSjzmVfcfO F5KNwAI25eyk0q+e0UEfNciL6s6N8qTipZbD7lGQ9GrFCUsLW0bVqUmWxRPkTji8jiGP clA2hQjSVeA8jdNbIHcQkTHFzeK9+HwLNBqhg9IVdq7jwdttVSl+UF+XJ6KXucAwyhme Kobw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713980720; x=1714585520; 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=nHy7p+TsVd61UoOXNyWftQk9Qj6gD334eWPgXT4ErEE=; b=hEGT/hN+ycXTgfTT3daeH9yXUVTyJ01jpbj8bGLvgyop0N6Twcf/aCvwYADzXjzwEt O9ETpc18QMQ479bh5P+gP7m/AlrojpIxgASROxmU4GAAxBfxKcl5jgBkLtk2lL84oSmP qgRn+Yq8qWyCDVQOUwSIYTmIMkIkireWA0PH8lc86IuYJOelOE0P8TmwjhyyfmNOOkre 1DM+x4Xrb9HTbtG0J8rdgLXtPpkJPcXhPGT5W+pfsUDYBCUPd4+7spJbE9WCfRRFcDqW H+LFxaJen18d9vU6IMdNjzWFLRMVmxBsxY4tKCxybs66MKQHl2GzqDkaqC9U+rl+ywLN aFHw== X-Gm-Message-State: AOJu0YzloicMVn7J+zb4U0rWefSt2hxnsNdgy9wAjZmeKTIFI0V5hXaN 1OK4TjDI4/E4gW2saNxf14+YtW4gVV9HjscKoQBaTS3BfRxa9A/zDMGs5i43lHEzzaJncmabhmV O X-Received: by 2002:adf:ea8c:0:b0:34a:9adc:c37a with SMTP id s12-20020adfea8c000000b0034a9adcc37amr1924659wrm.10.1713980719950; Wed, 24 Apr 2024 10:45:19 -0700 (PDT) Received: from localhost.localdomain (mon75-h03-176-184-51-42.dsl.sta.abo.bbox.fr. [176.184.51.42]) by smtp.gmail.com with ESMTPSA id s15-20020adfe00f000000b0034b03d0b94csm9059925wrh.74.2024.04.24.10.45.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 24 Apr 2024 10:45:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil Muthuswamy , Roman Bolshakov , Alexander Graf , qemu-arm@nongnu.org, Cameron Esfahani , Reinoud Zandijk , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/3] accel/nvmm: Use accel-specific per-vcpu @dirty field Date: Wed, 24 Apr 2024 19:45:05 +0200 Message-ID: <20240424174506.326-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240424174506.326-1-philmd@linaro.org> References: <20240424174506.326-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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 autolearn=unavailable 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 NVMM has a specific use of the CPUState::vcpu_dirty field (CPUState::vcpu_dirty is not used by common code). To make this field accel-specific, add and use a new @dirty variable in the AccelCPUState structure. Signed-off-by: Philippe Mathieu-Daudé --- target/i386/nvmm/nvmm-all.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index 49a3a3b916..f9cced53b3 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -30,6 +30,7 @@ struct AccelCPUState { struct nvmm_vcpu vcpu; uint8_t tpr; bool stop; + bool dirty; /* Window-exiting for INTs/NMIs. */ bool int_window_exit; @@ -507,7 +508,7 @@ nvmm_io_callback(struct nvmm_io *io) } /* Needed, otherwise infinite loop. */ - current_cpu->vcpu_dirty = false; + current_cpu->accel->dirty = false; } static void @@ -516,7 +517,7 @@ nvmm_mem_callback(struct nvmm_mem *mem) cpu_physical_memory_rw(mem->gpa, mem->data, mem->size, mem->write); /* Needed, otherwise infinite loop. */ - current_cpu->vcpu_dirty = false; + current_cpu->accel->dirty = false; } static struct nvmm_assist_callbacks nvmm_callbacks = { @@ -726,9 +727,9 @@ nvmm_vcpu_loop(CPUState *cpu) * Inner VCPU loop. */ do { - if (cpu->vcpu_dirty) { + if (cpu->accel->dirty) { nvmm_set_registers(cpu); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } if (qcpu->stop) { @@ -826,32 +827,32 @@ static void do_nvmm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) { nvmm_get_registers(cpu); - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; } static void do_nvmm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg) { nvmm_set_registers(cpu); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } static void do_nvmm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg) { nvmm_set_registers(cpu); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } static void do_nvmm_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg) { - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; } void nvmm_cpu_synchronize_state(CPUState *cpu) { - if (!cpu->vcpu_dirty) { + if (!cpu->accel->dirty) { run_on_cpu(cpu, do_nvmm_cpu_synchronize_state, RUN_ON_CPU_NULL); } } @@ -981,7 +982,7 @@ nvmm_init_vcpu(CPUState *cpu) } } - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; cpu->accel = qcpu; return 0; From patchwork Wed Apr 24 17:45:06 2024 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: 791530 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp965281wrq; Wed, 24 Apr 2024 10:46:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWg4pv9b1DF/GS4q1/+NtZMlYbPZ3mD7ZemkFOPJlKSHfnYzCQ5V4cVIfRftCIeJifn8eJcCdnNnz9CMpFjY7NV X-Google-Smtp-Source: AGHT+IFJDioMndm8qbZSQWMdSmQxthD6ieceoHUkpkYNltqRBJx5FM2KhMcLDKLD8u3FLxSZYAEC X-Received: by 2002:a05:622a:1908:b0:439:ed56:3eaa with SMTP id w8-20020a05622a190800b00439ed563eaamr811233qtc.6.1713980768420; Wed, 24 Apr 2024 10:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713980768; cv=none; d=google.com; s=arc-20160816; b=b98xZkA1P6rCHQYOsyaDuBy9kToCXat4jmrOyrZ21mgBTdpMj5Y2OmKi4SvVbejuk1 k3PIZez8bzCgjHsQYLuIagYcja1pHcE1mT0F9T3WaRANhQwYj/4xswbj2ay/+f5j98Xj Y9SN9abYqbsW5NOMIVmtnU4in9olgAce0wtPk1OSmeV8kz3vJHpANa+k2FeZ2gxghKiq Q8yPNKig5G/jH9Ppvi2jwyKuK2feT4dVGLNfwc/eyhZDYxkY3vKx3T4XoRuZ+8KJ4U+G d7K36YTAK9s/lOzy9ybOhfSlbDEby3udCuRQWZ2Mp8NK/NIcDhiChsb+uiO/QyAntt5u uvnw== 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=S1vG3j9SklDspIE1oKgdKXBwljECYteot2YkVWDa25w=; fh=UZI2xaj6P0caFCy7Huss7YTLsPa8Y5iSXeFncPqLo0w=; b=VA95R6bRqV4Qgypb8ykDjsInIuDkIzRFhXvFNRnhAERyphrJeuvYihLXlxluLKCJOx a4aZAgjWFyuB5Zc085tWHTJJGOFDy9Q8fIoVZuwhJYiG7/a12ZYBjDpVLfw4cRBky8uj hp2UPFOgFbx1YhVM/NQ8IhrgGcYxHAzDuvqYDBx8cKZVYEYQuuF13fqs5OQ4iah1qNFy V2zlejaTLM1K9w9fxMJhJuF3SF+ZPzyKO2KbxV9pAwFHJ/Nsygg7uN8ARyrvPKHyq5VF AWL6krlcr3FmNq88mOzggD5laX85xG2WrT00gRvRQvP325h/SzqqxtXxndBl3C6/Rf4u zEYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hDzKW/7I"; 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 m18-20020a05622a055200b0043981f5c70dsi9989133qtx.308.2024.04.24.10.46.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 10:46:08 -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="hDzKW/7I"; 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 1rzggt-0005lC-0p; Wed, 24 Apr 2024 13:45:55 -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 1rzggT-0005Nu-Es for qemu-devel@nongnu.org; Wed, 24 Apr 2024 13:45:29 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzggR-0005c3-Jr for qemu-devel@nongnu.org; Wed, 24 Apr 2024 13:45:29 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-41b31e2788aso815215e9.3 for ; Wed, 24 Apr 2024 10:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713980725; x=1714585525; 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=S1vG3j9SklDspIE1oKgdKXBwljECYteot2YkVWDa25w=; b=hDzKW/7IPUHiYbbr6SUp5RbE5KuB8q41m8XT8fgDeOj/OUPrzpl14OCxE0yEuxQjkk xtvmklVVxZjgQKkz5MUrxdl7yAM0EmaTiXdZNDx8cMj4Jxgfp+cXjZ9QX5xDNCCOaIoG GhhHKIakivf/RHw6AYHweKNYTFSe+jjK8jdXqt6AzKo+1BILHQJna3gcBIDZY1mpMGju EGmzoytPBl/1YllW8OmXrEW6JgWb9wFBgpfbSu0dx4DK50oR6sjEzd0/2K8ZBruxVTFJ muVsO76ll1HB0d8z2TZql2A3cwQUthlY+EzdAdruztJ+BfqA61qYbmIY8XkFfOkv73vP DN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713980725; x=1714585525; 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=S1vG3j9SklDspIE1oKgdKXBwljECYteot2YkVWDa25w=; b=blImnqfXW502zuIqZoaXRz/c1DB11EEcloOMNerSrWPyq9ehaA/KQgtZVcUugZIFeb 9QJv3I+8iSq3Ghv/LM3m6k1udoUED2nkJRQn3/KAoAU3AFVfI/aE1NcuE+usU00JuMr9 niLhrscwhJhL8RvWDciTVNJgfqoAQruMMVxPg2/v3Hc1F1yl7pkFXkDTjhZf3OZ+rEzM 1puEHBPpUf2aDnzOoXjTdO4GZUAqabxGfHprM22qopSS6ky8PbvpFDml4fxV63OKLBWh Nwe828Bkvol5kxeuKgK012nuf7zIbuV6nirKcsOkyZ07FEqbn72pfYY38nUTMHa7we+N 5r7w== X-Gm-Message-State: AOJu0Yz/O42+pO7jK5a0LJG+/EVLJ5+arAOshXfIV4i/hXxOKD8/OvxK letx6J167o0J2i8+3GZRDRyFYAEJuPxaQkgcOl214LS4cfO/eLTTPvYyfgKCWxjZ7tkddOfxaTi G X-Received: by 2002:a05:6000:1e8d:b0:346:b778:eaa7 with SMTP id dd13-20020a0560001e8d00b00346b778eaa7mr1923315wrb.18.1713980725528; Wed, 24 Apr 2024 10:45:25 -0700 (PDT) Received: from localhost.localdomain (mon75-h03-176-184-51-42.dsl.sta.abo.bbox.fr. [176.184.51.42]) by smtp.gmail.com with ESMTPSA id a3-20020adffb83000000b0034b32e5e9ccsm7253936wrr.64.2024.04.24.10.45.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 24 Apr 2024 10:45:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil Muthuswamy , Roman Bolshakov , Alexander Graf , qemu-arm@nongnu.org, Cameron Esfahani , Reinoud Zandijk , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang Subject: [PATCH 3/3] accel/hvf: Use accel-specific per-vcpu @dirty field Date: Wed, 24 Apr 2024 19:45:06 +0200 Message-ID: <20240424174506.326-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240424174506.326-1-philmd@linaro.org> References: <20240424174506.326-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 autolearn=unavailable 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 HVF has a specific use of the CPUState::vcpu_dirty field (CPUState::vcpu_dirty is not used by common code). To make this field accel-specific, add and use a new @dirty variable in the AccelCPUState structure. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 3 +-- include/sysemu/hvf_int.h | 1 + accel/hvf/hvf-accel-ops.c | 10 +++++----- target/arm/hvf/hvf.c | 4 ++-- target/i386/hvf/hvf.c | 4 ++-- target/i386/hvf/x86hvf.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 6f5a16e0fc..46b99a7ea5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -505,6 +505,7 @@ struct CPUState { uint32_t kvm_fetch_index; uint64_t dirty_pages; int kvm_vcpu_stats_fd; + bool vcpu_dirty; /* Use by accel-block: CPU is executing an ioctl() */ QemuLockCnt in_ioctl_lock; @@ -526,8 +527,6 @@ struct CPUState { int32_t exception_index; AccelCPUState *accel; - /* shared by kvm and hvf */ - bool vcpu_dirty; /* Used to keep track of an outstanding cpu throttle thread for migration * autoconverge diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h index 718beddcdd..4a327fd526 100644 --- a/include/sysemu/hvf_int.h +++ b/include/sysemu/hvf_int.h @@ -55,6 +55,7 @@ struct AccelCPUState { bool vtimer_masked; sigset_t unblock_ipi_mask; bool guest_debug_enabled; + bool dirty; }; void assert_hvf_ok(hv_return_t ret); diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index d94d41ab6d..40d4187d9d 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -204,15 +204,15 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) { - if (!cpu->vcpu_dirty) { + if (!cpu->accel->dirty) { hvf_get_registers(cpu); - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; } } static void hvf_cpu_synchronize_state(CPUState *cpu) { - if (!cpu->vcpu_dirty) { + if (!cpu->accel->dirty) { run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL); } } @@ -221,7 +221,7 @@ static void do_hvf_cpu_synchronize_set_dirty(CPUState *cpu, run_on_cpu_data arg) { /* QEMU state is the reference, push it to HVF now and on next entry */ - cpu->vcpu_dirty = true; + cpu->accel->dirty = true; } static void hvf_cpu_synchronize_post_reset(CPUState *cpu) @@ -402,7 +402,7 @@ static int hvf_init_vcpu(CPUState *cpu) #else r = hv_vcpu_create((hv_vcpuid_t *)&cpu->accel->fd, HV_VCPU_DEFAULT); #endif - cpu->vcpu_dirty = 1; + cpu->accel->dirty = true; assert_hvf_ok(r); cpu->accel->guest_debug_enabled = false; diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 65a5601804..db628c1cba 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -806,9 +806,9 @@ int hvf_put_registers(CPUState *cpu) static void flush_cpu_state(CPUState *cpu) { - if (cpu->vcpu_dirty) { + if (cpu->accel->dirty) { hvf_put_registers(cpu); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } } diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 1ed8ed5154..e493452acb 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -419,9 +419,9 @@ int hvf_vcpu_exec(CPUState *cpu) } do { - if (cpu->vcpu_dirty) { + if (cpu->accel->dirty) { hvf_put_registers(cpu); - cpu->vcpu_dirty = false; + cpu->accel->dirty = false; } if (hvf_inject_interrupts(cpu)) { diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c index be2c46246e..1569f860eb 100644 --- a/target/i386/hvf/x86hvf.c +++ b/target/i386/hvf/x86hvf.c @@ -427,7 +427,7 @@ int hvf_process_events(CPUState *cs) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; - if (!cs->vcpu_dirty) { + if (!cs->accel->dirty) { /* light weight sync for CPU_INTERRUPT_HARD and IF_MASK */ env->eflags = rreg(cs->accel->fd, HV_X86_RFLAGS); }