From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164723; cv=none; d=zohomail.com; s=zohoarc; b=A9xWadG6Sn2Rs8icu+YEaWqEXJGpobOE6fpNjwKvx8hVYNP43KvJpiEy4nJz6ypdpvMPaJ7lteZBjP+w+kwvV0c6iiKEsV6ydpecY1yMwTNBYgTPjtsbypBMmkUDoJpWtlvZKb90nBVdyHC4HP77kKPJu9yplLIjlmgRaDYtQak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164723; 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=5rAlH1/lu+rh7awee2lje3uE1FvJDSXtcSFDkovTFo0=; b=Y9EoNGHnVPsvXeQNYsno59f4UjfTrkR3ejEfUseZjqm/aCgYTl3fNX3SohVGa2PbKsyASt4mhbnooM037vtaAysQKAyafAi6FqjZJy5nf3RpB0Fi58E2amkOYKchHF5x7sB7xBdEzs/zpse/oad+u0pflW48JgkWSvaPW7DzN/w= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164723742369.33279214311165; Mon, 3 Nov 2025 02:12:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrWw-0002tm-PT; Mon, 03 Nov 2025 05:11:18 -0500 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 1vFrWv-0002t9-KL for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:11:17 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrWo-0002Ms-Ov for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:11:17 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-475ca9237c2so22231065e9.3 for ; Mon, 03 Nov 2025 02:11:07 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c2ff714sm145460205e9.8.2025.11.03.02.11.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164665; x=1762769465; 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=5rAlH1/lu+rh7awee2lje3uE1FvJDSXtcSFDkovTFo0=; b=W9Z6f/WFLSs1dKubvM7c7XENY0XLmGLj6HJYLAbCHwjzu3/bNpJRH8luXTACSlaciD 1n4hEUnqDvayfJ0iZVxIg3rhk8+xExNYYqZIJGVxN9d2l9bE2qQQ4df+y3+kw944uRlp fTVc77u/+ropXR42E37vnGLt+F5GI5KMONql5Mz0t1vGLtX1fCv2HJTwNaOzRLOZ8cot H7ExkWrPW4R/bIoUDPD/RLJY0UsGbbD/Z3Xg+pg+54io3qZZwQii8zc2sEl4f5/U0YEC BqIAn/4KR2RUNT8AuCjuP2m1x+7f/Ha3SNufZuUo8pD/Bnvs4Lu3ZJ8AoskUqHutXizm xY7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164665; x=1762769465; 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=5rAlH1/lu+rh7awee2lje3uE1FvJDSXtcSFDkovTFo0=; b=WKg9/aco+aA4P2J0iohBP4z0dDpzZ8ilMjSa/sfd4ba8YZCMihKLcpbdpubpYO+sce Pu0QDrMTR2TNXC68H1ZINn4LS9VqE5jnutWI9V6h+6dEjbdR0PNfs8bY8dr+PDZi8u9e zKYOL7YRXd/kxHu2g7MCcvm9POGkI3RmQp6K7GVcIAXnreEG9UCLT4QLGvnJLvo072VU KPLkA9oHGurIcutX1I15H2ItUQA1s03toNFJBoOvv5+mnz/kwAiIizxxHtYhSXb4Hjn5 mS6rnBBGZt5tnMi8RXHmD/j1V4oS6QQEQMjJBgZOgM8xEgIgeibpkW4c+GH6ub7Qs5ak yGjg== X-Gm-Message-State: AOJu0Yz8zhVXJZEBvqlLDXB5lE8TblKaa+Za4szxVwSdmhnHJdoSYGb7 VxoI/G22G0FU+KmevmL6Xg7ZmQdoO+/ZJcsri3W14B9KFJFQ4vwygx74YVUkbh9K/VXSSLH6zze AWQGZ3ag= X-Gm-Gg: ASbGncvOoeQxL1DqgnIdkryQdaMJbUkSF14/KDJDBD+t62fy8/v1tYcbrSztiYFmiWg 7omlVZ6VqmIfk9x0om/YaeYTn2ERhiNexkMewVWbAl2f1NXbfytJpuJ0IQNbItGyZ1EzEyrcvT6 h5NoLu6ncBO/AV64BwxauSsKCme1Sc0sayy10lUspeLNJb3tVwlVnkd8vVdVr8k/zWPxhalaSXb YxqTW42bKgneWQTpK8+uGkAVxmV5lS7iMs84c5LaJSM1RQgRfbsC2YrtqklIWyXTlXWGce57uGs eac+o7I9Mljuq5zL5sgjA11hiVwx9YEuqfpVir7hSBi+Crb0XCPLzA79M789epmqFct1CeIw1PA 7aN8vAhvZsZud/v9u3sQaPZ6jWmFxfShjT67s19KFtCW7o6iAXh+5dhgZtVvKG2kbOBXWITmQR0 4xWP5hX/xyhmBl7kqcH1/6s5KVbrMWXBkIHaF11f6hXHirbREm40YXB7nSEKXhxvAs7y+cQg== X-Google-Smtp-Source: AGHT+IHs/P5YscPj+tiHtkpPgXXoxry5aWicGkm7sN3Y5SjwmybunJib5OIWFCd+Nq4DsHykxWj25Q== X-Received: by 2002:a05:600c:1553:b0:471:16e5:6d7a with SMTP id 5b1f17b1804b1-477307ba7d2mr101696115e9.13.1762164665037; Mon, 03 Nov 2025 02:11:05 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 01/23] accel/hvf: Create hvf_protect_clean_range, hvf_unprotect_dirty_range Date: Mon, 3 Nov 2025 11:10:10 +0100 Message-ID: <20251103101034.59039-2-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164724995158500 From: Richard Henderson Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/system/hvf_int.h | 3 +++ accel/hvf/hvf-all.c | 25 +++++++++++++++++++++++++ accel/hvf/trace-events | 1 + 3 files changed, 29 insertions(+) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index 3d2be4092ef..5a57691885f 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -89,6 +89,9 @@ int hvf_arch_get_registers(CPUState *); /* Must be called by the owning thread */ void hvf_arch_update_guest_debug(CPUState *cpu); =20 +void hvf_protect_clean_range(hwaddr addr, size_t size); +void hvf_unprotect_dirty_range(hwaddr addr, size_t size); + struct hvf_sw_breakpoint { vaddr pc; vaddr saved_insn; diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 0a4b498e836..e13abddbd9c 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -58,6 +58,31 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *fil= e, unsigned int line, abort(); } =20 +static void do_hv_vm_protect(hwaddr start, size_t size, + hv_memory_flags_t flags) +{ + hv_return_t ret; + + trace_hvf_vm_protect(start, size, flags, + flags & HV_MEMORY_READ ? 'R' : '-', + flags & HV_MEMORY_WRITE ? 'W' : '-', + flags & HV_MEMORY_EXEC ? 'X' : '-'); + + ret =3D hv_vm_protect(start, size, flags); + assert_hvf_ok(ret); +} + +void hvf_protect_clean_range(hwaddr addr, size_t size) +{ + do_hv_vm_protect(addr, size, HV_MEMORY_READ | HV_MEMORY_EXEC); +} + +void hvf_unprotect_dirty_range(hwaddr addr, size_t size) +{ + do_hv_vm_protect(addr, size, + HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC); +} + static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags) { struct mac_slot *macslot; diff --git a/accel/hvf/trace-events b/accel/hvf/trace-events index 2fd3e127c74..f989da59492 100644 --- a/accel/hvf/trace-events +++ b/accel/hvf/trace-events @@ -5,3 +5,4 @@ # hvf-accel-ops.c hvf_vm_map(uint64_t paddr, uint64_t size, void *vaddr, uint8_t flags, cons= t char r, const char w, const char e) "paddr:0x%016"PRIx64" size:0x%08"PRIx= 64" vaddr:%p flags:0x%02x/%c%c%c" hvf_vm_unmap(uint64_t paddr, uint64_t size) "paddr:0x%016"PRIx64" size:0x%= 08"PRIx64 +hvf_vm_protect(uint64_t paddr, size_t size, uint8_t flags, const char r, c= onst char w, const char e) "paddr:0x%016"PRIx64" size:0x%08zx flags:0x%02x/= %c%c%c" --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164738; cv=none; d=zohomail.com; s=zohoarc; b=DD5lDpxImj6ZVFcbwJHnAlkBv3ui2fp4jswxcw4VGM6mlAbfVlVu/SXd/qdOYFXMwPC90WLMeN7k6U1U1oyXDKKEJuTC7vqIsWt2HYmOjujP2KwUZY6ct0B0JSX6MMdFySEqQLhyAMnsMFhkijkwNVpQen8A9sZ4Pr+FuZ7g0zA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164738; 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=rvdpQqu+6tXXSi2BeJVnKSBoAv9PMGvcr8JslOxrI6M=; b=ba57cyLdLBe3Z1utXJDg678ZHsbsMdlNIM9g7RHbNMHmPSnyfXwmxjUOePvm+hekgK2QBcD72qdkDxAnYgTBgQw6cGMnxrYl34Y/UsTT8NBGTWx2++pzRnxtvcQ0d1/H/fL6SXzya+EF0axY0Z2iVvZuT8E9o1WbuQiINQCkhtg= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164738559518.2135905184042; Mon, 3 Nov 2025 02:12:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrXL-0002xJ-L4; Mon, 03 Nov 2025 05:11:43 -0500 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 1vFrXK-0002xA-Hm for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:11:42 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrXC-0002XS-R1 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:11:42 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-426f1574a14so2568713f8f.3 for ; Mon, 03 Nov 2025 02:11:34 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c1125ad0sm19770172f8f.13.2025.11.03.02.11.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164692; x=1762769492; 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=rvdpQqu+6tXXSi2BeJVnKSBoAv9PMGvcr8JslOxrI6M=; b=EF6jwDrxSTYt0Wq4ilEpWSO62nclplJ8ttOH7ZAhAqfjupBjJ+TckZ75Eji4lMyj6+ ZWqHusYfhoX97ttuex0wh7I0OD5HRlQNTBvPKSF3aH7bOk0F5yycZdP4Ts46IjfjwdO5 pDRbugWJ/eVxMUSwdhUB8hVk3jDgiyQgQfNLZu6izIfgJVc4DuXN9W5IPBQXfroOW0zQ 9+2oABCuD2L7c1hpGXTqwqF7nKeBjd8UKynceNLexmm/ff6K37JpWoxRAkG6h0CZ+j/o 8b5fkP0IqchGRngARpw9vBXQPXWzjdNwcxEFne4aG0kx76wus+gVoKCfD1hhdZ1dan2l sQpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164692; x=1762769492; 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=rvdpQqu+6tXXSi2BeJVnKSBoAv9PMGvcr8JslOxrI6M=; b=CcNtxwnfJ5Dfesz14XlGIcSpXqEQL5bSEWzxCDxXksKmrvbm2jOydXhoJjyxWvGMY4 sIausXWmlKg8f5v3dNSCJqVmMpDGnn/h6KXy4N77s1MxR+UA0Mo88cQLY3ChHrWwnlZf tmyFLnEjY86d6/ykJTKC+NBdtelawgNgipeOBt7yLubo8eAbOzK/bNinOQ7+JZJALzP4 JNqiMkbuSpbSRfc0uSVBAVuTp/cXg/nL4FzJE45svq+d7LfjuBmVUgfYqRLZbbnYX4vj 3Ww/WEBkTVbSQr630WUhbhcpqpZmEfmBLVkFBBD1RnTT+nzdlwow2cD2ZS4rvV6w/A1m wYQg== X-Gm-Message-State: AOJu0YylvV94AtgTkg4r734Xhd4lhHwbCkc6z/l7i9dF3nCKHDSthRlz kaRXQ4UYDeSFDW9d92qNu2iG0DQahaW3nsiTVW4S5Q+VHx5PXhC5nbe4Xj5LBwsitvdkkcJAdUm BHp1QaI8= X-Gm-Gg: ASbGncv9crKT2AlI2uz0W3PBvrBJ1b8+S1/4PcGKW03pU3t94bioGs+YKBdwVxAyPKu N7zz6Be5kxzz0Oofdm227aKXtpfuZAm+XizklWYfxLBusVFED+L7QgajafCT1xmEKdIj7ct0vb5 3fy9ewlheiHtBZPVju3Shl99ukcDIJSd5WWLbothEu4zbantiwKBcvUSkhemo8w/LjM7F+nL6/J QHeoN1GX5R9GKICqptR5FEBXAJRrxesarQtRa8ARZMyoFGtHcfPk+r3pQAM9eFczqH1fihtCX4/ P4NMkqiyj+MrBY0L1gzcjzDLZcpaM8qq14GEmhGGndub34ctIxx3b3MF8HQX8I+hd0J+UuQO2aK 92lyhc0nL8mhAbs5EeF4e6vgO/0VdDb4WsdQXBcgIEFmcBPKcAcatv4tnn4MLZoUQnstetK/fIp 96Jv8iqxK4TNMYQTUwpnc2i5UIjqPwe/oRHodnsRexZJ7LsZ4f9gt66iwDdERdWvuRQ1Gf5A== X-Google-Smtp-Source: AGHT+IE9lsqLlSOEI/P1WSyQb3ydqWLetKEiFWATx2PIl7ZWPsfmfrIBEEo13jhxiaVxfTlw1LQltw== X-Received: by 2002:a05:6000:2510:b0:429:d6dc:ae0f with SMTP id ffacd0b85a97d-429d6dcb154mr1113674f8f.49.1762164692269; Mon, 03 Nov 2025 02:11:32 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 02/23] target/i386/hvf: Use host page alignment in ept_emulation_fault() Date: Mon, 3 Nov 2025 11:10:11 +0100 Message-ID: <20251103101034.59039-3-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164741171158500 While on x86 the host page size is fixed to 4KB, it is better to call qemu_real_host_page_size() for consistency. Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/hvf/hvf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 16febbac48f..9a1bf026a4a 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -76,7 +76,7 @@ #include "qemu/main-loop.h" #include "qemu/accel.h" #include "target/i386/cpu.h" -#include "exec/target_page.h" +#include "exec/cpu-common.h" =20 static Error *invtsc_mig_blocker; =20 @@ -137,9 +137,12 @@ static bool ept_emulation_fault(hvf_slot *slot, uint64= _t gpa, uint64_t ept_qual) =20 if (write && slot) { if (slot->flags & HVF_SLOT_LOG) { - uint64_t dirty_page_start =3D gpa & ~(TARGET_PAGE_SIZE - 1u); + uintptr_t page_size =3D qemu_real_host_page_size(); + intptr_t page_mask =3D -(intptr_t)page_size; + uint64_t dirty_page_start =3D gpa & page_mask; + memory_region_set_dirty(slot->region, gpa - slot->start, 1); - hv_vm_protect(dirty_page_start, TARGET_PAGE_SIZE, + hv_vm_protect(dirty_page_start, page_size, HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXE= C); } } --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164741; cv=none; d=zohomail.com; s=zohoarc; b=OlgVkd4FPFVJwaO8ZbJKw+aXiWuwYj2JiJuc1SuQ/JSVmSsk6pU36LnZbRKH8EWZcLQy5CwEYM2BBH9w7Uzv7aE/Z/T1DLBDJ/4ey4CFQEdQMAto4erE/M0Ap6EyN94of4yQJaRqIqd3kV7B0PmIqfIh0W/f9dVJzlEIlxlqZWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164741; 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=OYZPdSjIdF/EKh7X/rENMynZwEwjU3Z8rLiFolDwON0=; b=YkhceEuECKUAUqZ+zh3K7KMWR8ZMEKGbGvsZsXoUBNcq7aVIYlWROlylm81+3GnJ507WhnzqlP9ge9CWbZ2eY8WnA5v9nXKhg0suLCtvgHVJD6Ep2ag4kIngJr5Qnj0uUfTrODp40zDX5S08aYlv+4AyQwLDdfutDGkaNsYQBMs= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164741222549.800501686038; Mon, 3 Nov 2025 02:12:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrXk-0003Ax-OI; Mon, 03 Nov 2025 05:12:08 -0500 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 1vFrXg-00039m-CX for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:12:05 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrXd-0002eF-Gn for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:12:04 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-475dc0ed8aeso28578655e9.2 for ; Mon, 03 Nov 2025 02:11:57 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c394f17sm147900045e9.14.2025.11.03.02.11.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:11:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164715; x=1762769515; 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=OYZPdSjIdF/EKh7X/rENMynZwEwjU3Z8rLiFolDwON0=; b=AO7j00GncKNzj+gAvIFfjc4XQmXMvsmLqYnojBrLrydetbEdcoyC20xPIXr3+1CrKc IvdOHOhg8QH7aeQkpUOqHgxUSmukoj+FjX/XZgggT3mrmyYuUezN/q6NV57wlUR+o3qu iQoCykBpekl92nz3VT+LgNZA+d5Pv3e5wjy9NyUt3QTCXpsld4q+Q0zxFYdOLihlbSvq O0nJVYpTbmvIoqHyQySocK77DJbjw0JzxIkj+vBoeO1/vN2cTr9eGz0rwxQQbIFLFgjA +Qe6U941hiUheO1vdR9UPJ6gFIfzHrQPB0CB3796VvSF7qBoRMwDj8t7TFUNWdTKTt0p CPjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164715; x=1762769515; 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=OYZPdSjIdF/EKh7X/rENMynZwEwjU3Z8rLiFolDwON0=; b=FMYXlvrZ9bK9ZcWnHJ5clxHFTrJhsANe6dJDb385X9UYrjZEuoa6apE/n+G35dHMEP BV7fmtFZEXxCRJyUv+NTlxEa4kZy7oNl1XXWQDg6vD9PlkJ4tCLkLZnOtq61fBaX3cr8 Y3OwQI5AGTaPlJJBpr9UnTqIl5BPy9Jh3PkzLcASUUcsEyas0G6BlEp7QUTQZHa+SpLu vcplg3BnkyM3aUWFL4sWNZf60ZQ1c6lA8MKpQzFfp56YD5SgqtygPQpAHGvPURa9TvG7 9j9j2mF4LpMXjQ8pq/3NcZWNTKQO2/4Ql246PRQNSBp8MFF6DSQ0FWaXftkSqW3ffmAm 4okw== X-Gm-Message-State: AOJu0YxkCJk1A6cwvVCrRiPoYJ7tSsYQCFVaIUTulHeeWXcyzCTVuzEW YRA0obqCwvBVxvDDUg0Un6FPE110oobX38HtZCIVoEL2dEndkW998A/O35Kb/sFynnDRQ/4VNop sKd5C3Ns= X-Gm-Gg: ASbGncs5GHkxbi2yhJYSCvNKEzJxYFxJjkPDGF+09SNQtPZhCyCTm9x1L8cRNp3N2Km T3smSac+5vMrKnLfHK7UOpb9DCUgB+tnnf7xSozoZ6G29B7ajgT1zyI6CI0/OmdpKCyUWFj22Xg gTVvUTogZDI/3kt3nhxbwmgt6gHQCE8ySpjzImouzumBnM4lsrya88DKupzJGYXO13vmYNKwAwz xZtSKV9SwLLMYClcEgmWozS8dD+VjaMWXM8ZMC6pAr03VzJAbSofz3B785ML9QNcLNgPoUymVFL UDscCFuoeu9z86BtyBuVTFHzgKn0x7pOO3l1F3GM7T/DtuXf0FEdSTPPLIe7MmnUKSxNaEbSmKS qJPT83+FdC/eoSIagjNUUJ5CPDNsY8P58zOz26oa8S037jNQj3SMDqxnMBmXnMunTwLMEKDDSuO 9dOxWOuseIMkCmp18L3LYtG2gS2XQey5oBBoiTe1cyFJQ9CDgc1R7Se8koDlc= X-Google-Smtp-Source: AGHT+IE+GJDLMYtFJNOPkm7KPKOTWkGtSs0/iFcriJ/W7Vb/SOZUWpfZ1K4+zVjOEZbqm0RD3Ijzeg== X-Received: by 2002:a05:600c:501e:b0:471:152a:e566 with SMTP id 5b1f17b1804b1-477307c2944mr99799625e9.13.1762164715408; Mon, 03 Nov 2025 02:11:55 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 03/23] accel/hvf: Enforce host alignment in hv_vm_protect() Date: Mon, 3 Nov 2025 11:10:12 +0100 Message-ID: <20251103101034.59039-4-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164744636154100 hv_vm_protect() arguments must be aligned to host page. Suggested-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/hvf/hvf-all.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index e13abddbd9c..cb029e4dd4b 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "accel/accel-ops.h" +#include "exec/cpu-common.h" #include "system/address-spaces.h" #include "system/memory.h" #include "system/hvf.h" @@ -61,12 +62,15 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *fi= le, unsigned int line, static void do_hv_vm_protect(hwaddr start, size_t size, hv_memory_flags_t flags) { + intptr_t page_mask =3D qemu_real_host_page_mask(); hv_return_t ret; =20 trace_hvf_vm_protect(start, size, flags, flags & HV_MEMORY_READ ? 'R' : '-', flags & HV_MEMORY_WRITE ? 'W' : '-', flags & HV_MEMORY_EXEC ? 'X' : '-'); + g_assert(!((uintptr_t)start & ~page_mask)); + g_assert(!(size & ~page_mask)); =20 ret =3D hv_vm_protect(start, size, flags); assert_hvf_ok(ret); --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164788; cv=none; d=zohomail.com; s=zohoarc; b=BI98R2jqVb3HQ96MpwPgDAH+V/0k6o/Sj5tbgZ8WhrZPhCCGRcogWz0YVZT60Q+KQN50a/eiYkPDPixuCEOQSmBFdgljIKMo8f01TEEcJBJ4GC7D4Q22dckMXIwt8N7HRKWTGnWTFiJ2gNuvSPSfvvyL/kxUGCmRidwNHeOkejg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164788; 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=3vM9mNF6BeM3+aPg+3EGb1A8W564ICSX9mM1UAAGdK8=; b=B6hk8fsmLNaFysjh0rUNoDex4O+W+cgz/5l/DNCukf0uUheV7pSElKctztzJbuetZ+2gJUqsHV7pgQ//8MiEP+KDZAKuACVkLPVJR1tj6pxyygY4HOm12clG+yHjgosrcD/w9MXZ5ntS7NWj+ahGqFCUxv23b/YrtxKOymLGnuE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164788723136.5883539602528; Mon, 3 Nov 2025 02:13:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrYE-0004KS-Vq; Mon, 03 Nov 2025 05:12:39 -0500 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 1vFrYC-0004I5-Nx for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:12:36 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrY7-0002mp-O5 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:12:36 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3f0ae439b56so2161995f8f.3 for ; Mon, 03 Nov 2025 02:12:30 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c140629dsm19493055f8f.46.2025.11.03.02.12.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164746; x=1762769546; 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=3vM9mNF6BeM3+aPg+3EGb1A8W564ICSX9mM1UAAGdK8=; b=Z36y27vVmPQydFEaIti7AYV8MqgdjHqDhBQrCLBJB7hRneD+tZZ0tB5oRySRUGWJzJ M5Wwryl5PEszBFSHI0RRYjlqtwfiKoseiBk/0mBOHQzyIvfH7D6iMsDN32pRhHElmMg5 1hi1TIBFrZc4stqgyl93/rZ9k/JxYj6b0AlX/VM4CnHbdPnQ9TUVt9DWrefboYv8rb9E 5+3nvxBF+bL18EARNWiFt2bXuBPojewn6cllPQ1CpYxW5/3FW9OyINmAK7c1p/PVLe0u xB1BqM17GCRWqzlySOrfReGRbGx7OXVq5IsQgj+6mJJpNb//4CIrtqUbM2/2uzbMEakc iaPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164746; x=1762769546; 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=3vM9mNF6BeM3+aPg+3EGb1A8W564ICSX9mM1UAAGdK8=; b=TCPP2+f5bAGDw+v01GD9bnZXpe3qnEGpkrT3qQkapIyFnYPOht+vZvII7sr98ivTNb 9YldNiRj9JNT8c8uZLHO5WUCoDIxpWPEfO6VCLce7m2Bm89tYdtyCW2mKHc1O5J/+MSZ LsVX3KRgNgx0BcsapFcWMOft09E+dDaUmGpkDruE6ZoneXFk1sXJes0Kj9Db2aZTpdhz orvfv9BMQ6X1hktPm1JNCA+OyxfUxosIYBMWfsZPJU7t7X5PMUM9HvKX6DcZEtZvBBRX kjO1PFlRCYbExAPY5Weg2bie4CuD/CJcT9/iwKewb3wFyPxkNCdlMPXWy022Io/ihJi9 A+Cg== X-Gm-Message-State: AOJu0YwAULRDLIzILLc2GjvGLFdSNWsJS/4jiFYAPSJ7U9rP3zYiQsSU ufZV0tsm0K8RGQWHHfdjejhzK6K3J1RBow7238f0854fKcC284eMrSgOgNA68Y7AIBM/DcYj0Ky No3OTQf4= X-Gm-Gg: ASbGncstT5HPGJ4PKQJmeVNmCwLfBrwupPTSJ63jz485wELVgVSqG0/p8Ap3y/WzeGn MDfc8GVGREHMS69/S2vCCLhxwfsCVuT+9pAUay+p2XDX48FgWmrptkrGlzjuoThYCscMLpn6HQL /SaQ/O67xSF4PRU636y5db8L10JOTlVeMPOUUoEpmkpz+SoSIwDYq6AByknFMoZn3RBTN6+MfHM gmzKnpbQcTJyVszPo+nJCD/qg+SJRCW9pbjAXXRNXM8B4dswyDX+s2ZGtkYpYWFcmSzmpIBEHDj f17OGfZTI12DAOGMfQlL82s8DDpRBHkQa9OQNx+TURTH60e3Mq2UEnLUzusUaAV+rTvn6SeBKRx Ois8dn57pixnpEsrLwEoHd6wWJt8ZIvSMl5bzGxwd62jbPFIP5TEhuyG60DCP5fssNTwHrEr3+0 5xERoKGMbHHQb5n7Z9LmWE2wM3mpE6JrrOmGXl3jvhNrWW2J2x+E3I9JHXfn4= X-Google-Smtp-Source: AGHT+IFqEE0AjlJKWmovmNuUbDchPT2JpzkrZvJo/FxdLCLy8kLvHUjaJtrdjEbML2bXg5UJJPsz/w== X-Received: by 2002:a05:6000:3110:b0:429:cacf:1064 with SMTP id ffacd0b85a97d-429cacf13b8mr4709120f8f.29.1762164745540; Mon, 03 Nov 2025 02:12:25 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 04/23] target/i386/hvf: Use hvf_unprotect_dirty_range Date: Mon, 3 Nov 2025 11:10:13 +0100 Message-ID: <20251103101034.59039-5-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164790477154100 From: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/hvf/hvf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 9a1bf026a4a..de06ec6125f 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -142,8 +142,7 @@ static bool ept_emulation_fault(hvf_slot *slot, uint64_= t gpa, uint64_t ept_qual) uint64_t dirty_page_start =3D gpa & page_mask; =20 memory_region_set_dirty(slot->region, gpa - slot->start, 1); - hv_vm_protect(dirty_page_start, page_size, - HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXE= C); + hvf_unprotect_dirty_range(dirty_page_start, page_size); } } =20 --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164811; cv=none; d=zohomail.com; s=zohoarc; b=GSMRXfW3bek3w1dSRZJ9MESWw8ryKzHnkHTub/qGbCy73QvILRlWq5DiHB3Lfv9qJLGDEpcY3MK40776yyxQKfhioBesQVdhPGs3p5ntadZJclTPTTzOpbtby2q96y8PXKMLEqjrzn4+fpyIHTV+nubPMg0lPlWgCJBIQ7Gg+U4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164811; 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=hddejy+RqNyWzp8USy+9Z4LwK1QwF0we3BKzrWx+KAA=; b=V+oU591lFOJ52Jc+gLz71uZ+pm5QjvdAqWgX9TQ6xAdCgqsXIWd8MJNVvq9TE2JOAHZQ12qoGmvFe2nZoOT11SAL6Y8AWvUIxQGK/M0zqjsdrx6jOAEXjkJT5c2NgFwt9B/A902Zk3EcA8GEjZMa0bRQfKZE18x5kAV7YBfdT4Y= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164811293350.5418612682647; Mon, 3 Nov 2025 02:13:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrYi-0004xt-PL; Mon, 03 Nov 2025 05:13:08 -0500 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 1vFrYg-0004va-IK for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:13:06 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrYT-0002vQ-PQ for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:13:05 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-47710acf715so20337205e9.1 for ; Mon, 03 Nov 2025 02:12:52 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c4af7c7sm149279335e9.7.2025.11.03.02.12.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:12:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164769; x=1762769569; 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=hddejy+RqNyWzp8USy+9Z4LwK1QwF0we3BKzrWx+KAA=; b=iUPdPKp94HWvR+qauFvAyMO6/wEH7JFrdUBy8h2bOsCFDVMGo7AIvToB8WOILRkLFj boDEH72xINXxCk0VVJmnGWTsHQwZzQ7l7MEVOGINepihn86+wxrESlr+Rh6kw5rkL7kW zofp/ZuC87RANrWfqn0NoFDTx+gEc/g8mElGxFzdMRYXsYDYQRwLRisW3moQ4fFtyhEX oVFvuD1LjXIBefi8PSxwgt8PFnkQONuf4WT26ZoQeuS80ErgCvr218/63B9YhJffAG14 kQ2bNGRdV+P8T44YYHpGFEw/0iEwbzhxZHRZvjh41OguC3UNQ4iChDT91jcJ4EO4ncFH VNeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164769; x=1762769569; 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=hddejy+RqNyWzp8USy+9Z4LwK1QwF0we3BKzrWx+KAA=; b=HT7gilt4TXv9eboSv+jPLLNDP65VpAzBSMg3S3JOVufYI/gjVeXdtp7PkN1VHRIHut kYi7wofQifiJzoBvCJ/BReyxuQ6vYlx5E2fji5Y3Fb8GsaRSIWwQc6qCmJV1pImlscu5 in40sClOp4qbwID6t2x9aa7uYa+uCy4tDGVLNhPhfHXR00N7W6kEtvNnrHgSE3sE9UX2 1YdjWqGUtC7Pk8Apey5Qj+8cKYf2OrW+CcRNaQOIR0F7o2UauuQRutke0guaJb8XtKHb 6Hvuy5AuT1ibrAvzYy+DnDDenZTjMW7ppdNOpNFR7/oXGSLVJMAtHKHzL8vCEtNaE/CL VKlg== X-Gm-Message-State: AOJu0Yxsvr0zTiRu1CTETJhrYgv3CaMHfwPKUN30sHdRDTh+EeHQUNxE yTQpmTy8ApxfbVnScROEU0+pWbdYWKMczOfo9RbZFkKBewyMlIW3EzYakaLHb3f+tXOrAtvuhqF hM/5SpNo= X-Gm-Gg: ASbGncuH/7M6FjgAdYDk/q+CsIZ+K1CvzCz5wz7BIZBxZG3tlkIatSls0OtT9fq3mL7 OkNJGLh9MbKWCAAAV7vPSHhKlx92z5gwN9P6qQLWOfPVZ4003eG91YTs2Rz8EMr2yIfiGz7VEEE i47oVUBGwj9BoqpD7NlwYjlCIhjLRPdyPJ28ZklWD2Wl3ovRAZD0cg0DekMzy8ypJpQQKVJGojc aNpeTmo6ryiwIHNt75aTK5oawNYqtNWiFfD0FGuPg19D5QhRe/cqQ59Ev4YY9F5n32VbAewRWxI qIedCyffetcfsV9sr7zOCOYrcdIP958mwm6G6wT1Kb5oxsxqZma+XxftzRC39+1ic6GWJONH/TU +R7CdkQ6Ir524o5gHS13vmWGY35UUVAnautJ2y2C0iMd7cFGlNo6SrCuZ0ylELBJkg7qQ2SBPYO GYbaUXN3B5glR3+AodqchuSKmwztdj9l/pTNti5fFJbkJyYB2i6ICG4Jvore7hSg8mXYU5DQ== X-Google-Smtp-Source: AGHT+IFlY39asyt24FXv7gpE4ECnU1pHD55fFXzazUblY7kazIn1omCLcl75SsgylZpTK5FDRdDa/w== X-Received: by 2002:a05:600c:6303:b0:46e:4be1:a423 with SMTP id 5b1f17b1804b1-477307b7e7amr93501465e9.1.1762164769020; Mon, 03 Nov 2025 02:12:49 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 05/23] target/i386/hvf: Use address_space_translate in ept_emulation_fault Date: Mon, 3 Nov 2025 11:10:14 +0100 Message-ID: <20251103101034.59039-6-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @linaro.org) X-ZM-MESSAGEID: 1762164817323158500 From: Richard Henderson The hvf_slot structure is a poor replacement for properly looking up a memory region in the address space. Use memory_region_get_dirty_log_mask instead of HVF_SLOT_LOG. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/hvf/hvf.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index de06ec6125f..d0ee00425f0 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -119,9 +119,12 @@ void hvf_handle_io(CPUState *env, uint16_t port, void = *buffer, } } =20 -static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept= _qual) +static bool ept_emulation_fault(CPUState *cs, uint64_t gpa, uint64_t ept_q= ual) { - int read, write; + bool read, write; + MemoryRegion *mr; + hwaddr gpa_page =3D gpa & qemu_real_host_page_mask(); + hwaddr xlat; =20 /* EPT fault on an instruction fetch doesn't make sense here */ if (ept_qual & EPT_VIOLATION_INST_FETCH) { @@ -129,21 +132,22 @@ static bool ept_emulation_fault(hvf_slot *slot, uint6= 4_t gpa, uint64_t ept_qual) } =20 /* EPT fault must be a read fault or a write fault */ - read =3D ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; - write =3D ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; - if ((read | write) =3D=3D 0) { + read =3D ept_qual & EPT_VIOLATION_DATA_READ; + write =3D ept_qual & EPT_VIOLATION_DATA_WRITE; + if (!read && !write) { return false; } =20 - if (write && slot) { - if (slot->flags & HVF_SLOT_LOG) { - uintptr_t page_size =3D qemu_real_host_page_size(); - intptr_t page_mask =3D -(intptr_t)page_size; - uint64_t dirty_page_start =3D gpa & page_mask; + mr =3D address_space_translate(cpu_get_address_space(cs, X86ASIdx_MEM), + gpa_page, &xlat, NULL, write, + MEMTXATTRS_UNSPECIFIED); =20 - memory_region_set_dirty(slot->region, gpa - slot->start, 1); - hvf_unprotect_dirty_range(dirty_page_start, page_size); - } + /* Handle dirty page logging for ram. */ + if (write && memory_region_get_dirty_log_mask(mr)) { + uintptr_t page_size =3D qemu_real_host_page_size(); + + memory_region_set_dirty(mr, gpa_page + xlat, page_size); + hvf_unprotect_dirty_range(gpa_page, page_size); } =20 /* @@ -156,9 +160,6 @@ static bool ept_emulation_fault(hvf_slot *slot, uint64_= t gpa, uint64_t ept_qual) return false; } =20 - if (!slot) { - return true; - } if (!memory_region_is_ram(slot->region) && !(read && memory_region_is_romd(slot->region))) { return true; @@ -764,7 +765,6 @@ static int hvf_handle_vmexit(CPUState *cpu) /* Need to check if MMIO or unmapped fault */ case EXIT_REASON_EPT_FAULT: { - hvf_slot *slot; uint64_t gpa =3D rvmcs(cpu->accel->fd, VMCS_GUEST_PHYSICAL_ADDRESS= ); =20 if (((idtvec_info & VMCS_IDT_VEC_VALID) =3D=3D 0) && @@ -772,9 +772,8 @@ static int hvf_handle_vmexit(CPUState *cpu) vmx_set_nmi_blocking(cpu); } =20 - slot =3D hvf_find_overlap_slot(gpa, 1); /* mmio */ - if (ept_emulation_fault(slot, gpa, exit_qual)) { + if (ept_emulation_fault(cpu, gpa, exit_qual)) { struct x86_decode decode; =20 hvf_load_regs(cpu); --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164840; cv=none; d=zohomail.com; s=zohoarc; b=KuqFN0fggTdProDyHRmcul7ug8u68+rkeKLZdSk4k18BXYOHfJ0bmc6WYZTTy7CzD7zyxt7TK9wOIGp35eVYt5yvmpURP/cD+rUICIU602VBKNHhoMxiLo6uOYIk8sD1TCdo2oEJ2/aetrRcotge8ndkarN57wX9LomAUNhEIj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164840; 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=J0L1rNSBbDA68/IWNXBGkYS13/51Kd8iUuA26ASfqQc=; b=nXdCM0kWq2qq5lj2pDKwvAKfCCXFHrXaYzyZaIXbcOxuyS1fkZHAfD+KJSENjPTHY/nYRlX5l/9r5qFAj4fo9iTdHBuX+lt18NkopVkbIG3ZUoAkxUEIHcA1R5jRfNzm4aUY9IDugCQnS0l4XSeif3hn4vQF4T4P7v4+b7H6WPc= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164840485501.7229035445488; Mon, 3 Nov 2025 02:14:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrZ7-0005G8-7z; Mon, 03 Nov 2025 05:13:33 -0500 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 1vFrZ0-00058F-Py for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:13:27 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrYu-0002xn-Ut for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:13:24 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4711810948aso29601105e9.2 for ; Mon, 03 Nov 2025 02:13:16 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4772fe0da3asm85728615e9.6.2025.11.03.02.13.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164793; x=1762769593; 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=J0L1rNSBbDA68/IWNXBGkYS13/51Kd8iUuA26ASfqQc=; b=D4rxOSNM03I9Sc9xptgO8YrgCbSfCcUKpF9Rx6f0bILgeuuwQ5izI0WK7KO/1BG5v2 yXnMXNZctYqoIeEkICIfGedytNBH9R3iu7dJ/nRlxAIAxRVrJ3rngyibvwMvPTE919xP LHSe0FNagqYysU90WM7Sq4qMq+0qXu83OkjLnQxZYt1+CzcTpRjrQJUSqMOeuO1Xwxmd a5GMv7YzHK/qNQarqa2Wl4U/fbrwVFHzvGSr3GRhFLD+Gdy/VisyiycHD7jrtJ6SvR44 OmdrMy69ZI8XPvy8hSpnFLDoxJ2iVjC4/qNd8c1WTvXFUAhv5WnZ4PUc3aLmLxUd2V8m IJFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164793; x=1762769593; 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=J0L1rNSBbDA68/IWNXBGkYS13/51Kd8iUuA26ASfqQc=; b=OaYXLI/UdjrbpphPGFaGAUNI5pMDdmAhaq7QbBQS8thHqgTh//5MduowufDWPbi7Kv zCyE3jMZhmBs6VMW0lQ+TuIWlKrHVYwFyBJOItTHSWHmy3lPIU9Ez8l8qev1HJyERTlF 4Q+DybKbT5x5IRoa9Kvb6H/LP/H2WGCcd0lUA5wjCCnFyXGHakmI10pTx1DjubYF1aLs FX9J/uTFfGYh1L+KnCpM9PL9EvHtMR0cs9ttj9s/lJGU0GiXfypgRVCNvn6WNWXRsdGY Qd1Z9XTa94ZpF2i/39XYb6AbRkMa/RmkbCjb349QPVhr9zMmhfn7TT0PRi3PANgIiCli 0Wmg== X-Gm-Message-State: AOJu0Yxwe9a8w6NULHfiJjCqFTlXBiXDQfH6mnlA27IWGz30VGLa50Fe Vbqcyoc34TTr/Sm/V65xAfwSUDBg41LOcs+D+/qN8u04a5d1eqR2JWolxp6S0uw3nqlWs2YY+Vv GejKIq8I= X-Gm-Gg: ASbGncugGUmAHFTu4m/OEcDOWHVpEj/LNkNRVzopy03Fv/ex46zWGuFhybiC7QH2ghA XW1gh9hY8heRRLkB9ZlKcPqFzg+YQs4k26MKcqU7c8kdSi2d3wl6jO+BMbXTID8m1Ib4uuNc8qn ug/rUOr6j+OJBr6hgeQyC3/hSSh7ZwISC/5D7tEEuKZHuLGTWL4qMNU+oZvIr6j/DlQbiWItM69 T/8jxelEoR5CuFYBOJFS5M31YKCYYmFzDxcKuEGr+e2Hd3RyTav3bqkMb8QTpLW65h6xbZrNw2Z 2A/kaEmB11ic4vKwdUDY8D43/mBl/2YC7CBa4d6XnUh5nOjvlAeMZE3UdKVTQ5f6jvPunPlFQz5 3TyBSFHEA0+4qB+BtfEiUcL/fB8SwGjoYW+MRRZ5NZmijr4BtxwSFulAk1IDY3WXfYOxG+58+zD c9lvOuVfsCVy/fKNCbXgMpXwdjljxP3vXQbncUX+d8Cw1YT7ZQnAigfyDk2yc= X-Google-Smtp-Source: AGHT+IFKiOsfs/H1/75JT2DpnBWXcqBuFxoYVJwBciVYxXmT59enPvZavBdmyeUIw6Lgw3CSqAnydg== X-Received: by 2002:a05:600c:8415:b0:471:1765:839c with SMTP id 5b1f17b1804b1-47730871f97mr85060715e9.20.1762164793101; Mon, 03 Nov 2025 02:13:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 06/23] accel/hvf: Simplify hvf_log_* Date: Mon, 3 Nov 2025 11:10:15 +0100 Message-ID: <20251103101034.59039-7-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164841057158500 From: Richard Henderson Rely on the AddressSpace and MemoryRegion structures rather than hvf_slot. Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/system/hvf_int.h | 3 --- accel/hvf/hvf-all.c | 40 ++++++++++------------------------------ 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index 5a57691885f..ee7ab689f45 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -24,9 +24,6 @@ typedef hv_vcpu_t hvf_vcpuid; typedef hv_vcpuid_t hvf_vcpuid; #endif =20 -/* hvf_slot flags */ -#define HVF_SLOT_LOG (1 << 0) - typedef struct hvf_slot { uint64_t start; uint64_t size; diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index cb029e4dd4b..601e63c7f9a 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -204,45 +204,24 @@ static void hvf_set_phys_mem(MemoryRegionSection *sec= tion, bool add) } } =20 -static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on) -{ - hvf_slot *slot; - - slot =3D hvf_find_overlap_slot( - section->offset_within_address_space, - int128_get64(section->size)); - - /* protect region against writes; begin tracking it */ - if (on) { - slot->flags |=3D HVF_SLOT_LOG; - hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size, - HV_MEMORY_READ | HV_MEMORY_EXEC); - /* stop tracking region*/ - } else { - slot->flags &=3D ~HVF_SLOT_LOG; - hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size, - HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC); - } -} - static void hvf_log_start(MemoryListener *listener, MemoryRegionSection *section, int old, int new) { - if (old !=3D 0) { - return; + assert(new !=3D 0); + if (old =3D=3D 0) { + hvf_protect_clean_range(section->offset_within_address_space, + int128_get64(section->size)); } - - hvf_set_dirty_tracking(section, 1); } =20 static void hvf_log_stop(MemoryListener *listener, MemoryRegionSection *section, int old, int new) { - if (new !=3D 0) { - return; + assert(old !=3D 0); + if (new =3D=3D 0) { + hvf_unprotect_dirty_range(section->offset_within_address_space, + int128_get64(section->size)); } - - hvf_set_dirty_tracking(section, 0); } =20 static void hvf_log_sync(MemoryListener *listener, @@ -252,7 +231,8 @@ static void hvf_log_sync(MemoryListener *listener, * sync of dirty pages is handled elsewhere; just make sure we keep * tracking the region. */ - hvf_set_dirty_tracking(section, 1); + hvf_protect_clean_range(section->offset_within_address_space, + int128_get64(section->size)); } =20 static void hvf_region_add(MemoryListener *listener, --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164858; cv=none; d=zohomail.com; s=zohoarc; b=LI2Daj55tELJd1d5ycXAYcxOF50+BlZcGQqgvUpijH7JxYYUhStve6BmsadgNhCkbad+NJDwtGV/yAuzgXAEQKBjfddW9x0nKUi3mv1RSi5Hs+zOaGNypmZp/Xwpi/MrWDh/ploY6Ul3U+6hXDF7RbkKYQ5dfOo413jiwR2j+cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164858; 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=ZhaKZtIHcKQyEzCs44RThvX4QVJ1Sgd9Tp4DxoQS0nM=; b=CbV6IJ79lQdGl8gm7ah343jtrsZTxw+MpPErc+43UgrkvsBW6nZf/Btl8/1BIVLWWTsv3xgzpuCwPIIpuryCIejqSInSBANSfDticGRQv3G5NAL+ino0zti4H624zIylDLd2OiVKZt3VSeupuL1kzTup05Bay8eUHCnbILDtZF8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164858211446.35454479306077; Mon, 3 Nov 2025 02:14:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrZT-0005eE-U3; Mon, 03 Nov 2025 05:13:56 -0500 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 1vFrZR-0005dX-UX for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:13:53 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrZM-0002zQ-Re for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:13:53 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-471b80b994bso54840955e9.3 for ; Mon, 03 Nov 2025 02:13:46 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c3a77b1sm148140115e9.17.2025.11.03.02.13.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164824; x=1762769624; 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=ZhaKZtIHcKQyEzCs44RThvX4QVJ1Sgd9Tp4DxoQS0nM=; b=elQ3XncFJ1cC0c7CLhV+9zkS56AkVxbfDtfvlc1Fd8fvMFfYnPav+8wxvYDCTWfl59 86RNoRzEPypDZFeVv8PmSdTRV6NTblAO/0A9dSOKLvA3agM2ppuEQOoO1UxwOdtjbtPJ s41VZbG4NuAT0kzW4WMQOgkyGPmdNvu+Ml7ImgOHH13/U4g2dwgyvADxUtxEb9XITJmo 5EMi2JiFnY0J4HAgDTPgRhUasp0hXcLT2+Tu5CU/wyO+PLpoLHH2cl7zXo8fHvzAIDa5 +NhXcJ4VYhl4Njh3NdSFFhxHygQKFXEdmfBAdcUa+n2Rp7ytDfQ6fsCDAxg2rzWjkExW GjhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164824; x=1762769624; 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=ZhaKZtIHcKQyEzCs44RThvX4QVJ1Sgd9Tp4DxoQS0nM=; b=p+nIjlSkAqH0/DL2j8zVGCTg9GLtT0dozNugpMvmO0dDZ6XB13nwRaHk/QtmL0wH1k h/EKT+4ycUMVwfg7mgNJFWnCQ9rp/IRoCBqQGw7H0KyE6+dX/88v3a0OQvXr0qLZON3p gKMQWBfU73xziA+C7Q16pM02u3th1YXcBfUma8JzwcodElWXLGcbKnYNXmPKBZGnF1iw x8SPMfvD6lwwRVXMuYwdCnIjHNbXkmVaEeQtcshhwmkbn0hBh9l0wLRJjkTo5m9fyZr7 vtcbARy03/2YG5bVwWjsFieQHyc5X0v5u9y4VmxNR1askE5mViv/YG/G9EUnpyUCXR06 FkPw== X-Gm-Message-State: AOJu0Yz4x54Ai3KliA17/PYz7xhoQcKrDiXmYqjP+wtbcuy6eNs9qcpt mhEtIqzZSlJbiyhbkh2yWRQcL3tqDGPFyDq3gV4O3FQGHo4aFDu75TYLF4d6LcBimDVfH07vzSK 6HlqYhQ0= X-Gm-Gg: ASbGnctw4Od3zgDGlBiTCRXbVg6JOt7r8/pwbrIgEcFn70+SlF5VSm86thYyFgkaZPS G+Pe6sMIO/aAZhOVeZMsmQauKlZgemcmx4ZH6WHxSOfJKeFYr1DcjGiVpqkug76X+dRxj5f81er F4rLmG/KaT3lfcYSzwoReiVmVXFA1SYCQ6Gxsr6+OK260hVGA3RM3cnrx4kOYEBvyoegXRo4LYc yjUzwRwZEBg1k9QEWowGpIB5CvoNXd/0ukHuWxWFDTuo2pzNJWMd3o8tLC3aCYvyQjrqiY9lcoj IbXesa3g4MdiLIO0dggRIoLl/bj9+kRVqO08LNMU+qN9PlUBnsOB3T8/SP6kd9HhrVac+dEfdnv zCFyP3Hlj55o+drzmbkRy1D8FUUfJ2nAjZTWJC4riU15c+siav/mfaszpj9zDLPgUfsHbQNRaEE jSR8RLmPZzpO7aCLwdAsEbhZYXr1foWKzjY56AX905XNx053JtAYoBiGnUuPg= X-Google-Smtp-Source: AGHT+IEOGKIgKnlbDQiyqHsOaaJCd31NLapA+qxZRnHzn1WG4l/u8lZPmyrB01DywGkze+48j6mTTQ== X-Received: by 2002:a05:600c:3e8f:b0:475:dac3:699f with SMTP id 5b1f17b1804b1-477307c1470mr105999275e9.9.1762164824081; Mon, 03 Nov 2025 02:13:44 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 07/23] accel/hvf: Move hvf_log_sync to hvf_log_clear Date: Mon, 3 Nov 2025 11:10:16 +0100 Message-ID: <20251103101034.59039-8-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164861229158500 From: Richard Henderson Right idea, wrong hook. log_sync is called before using dirty bit data (which for hvf is already up-to-date), whereas log_clear is called before cleaning the range. Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/hvf/hvf-all.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 601e63c7f9a..f203a6251f0 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -224,12 +224,13 @@ static void hvf_log_stop(MemoryListener *listener, } } =20 -static void hvf_log_sync(MemoryListener *listener, - MemoryRegionSection *section) +static void hvf_log_clear(MemoryListener *listener, + MemoryRegionSection *section) { /* - * sync of dirty pages is handled elsewhere; just make sure we keep - * tracking the region. + * The dirty page bits within section are being cleared. + * Some number of those pages may have been dirtied and + * the write permission enabled. Reset the range read-only. */ hvf_protect_clean_range(section->offset_within_address_space, int128_get64(section->size)); @@ -254,7 +255,7 @@ static MemoryListener hvf_memory_listener =3D { .region_del =3D hvf_region_del, .log_start =3D hvf_log_start, .log_stop =3D hvf_log_stop, - .log_sync =3D hvf_log_sync, + .log_clear =3D hvf_log_clear, }; =20 static int hvf_accel_init(AccelState *as, MachineState *ms) --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164915; cv=none; d=zohomail.com; s=zohoarc; b=TMHul/a36CQgwIGC6VrRloN3V+/eHmKsoxim5i0CDCez4SQi8x1dGVon2KRBUY9dzA36GY/E1kqC/KyRnnAHqIMNlfyNuAuyFgcfque8EAEXit2gwJpsAWjOvYwJlPOLN4upsTiBlbM1/iPowUnP7H4y6yY1FehM5FD/gsd713Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164915; 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=hhmyK4oEIpSWjXpku9unHriewKy+XN/2ZADa1rxHLbo=; b=WUbAN1n58+3FPQiKW61iAZL2iE36o3yAH9h6GzhV8i263+njrrIqmud7HvHN4lLbzV/V1PT5yMHJOAT/oQH3bpY+fHJVq8nmoWyU1F19xwAS2k8/x2mcJ1h85N1BCsuqTcY1Bo4YWs5epiERxcZrdl/XPHjCQin2fKE6YupPUnw= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164915142860.6287461186948; Mon, 3 Nov 2025 02:15:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrZs-0006AQ-Cd; Mon, 03 Nov 2025 05:14:20 -0500 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 1vFrZr-0006A7-45 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:14:19 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrZl-00031G-4w for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:14:18 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-47721293fd3so22617155e9.1 for ; Mon, 03 Nov 2025 02:14:11 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c583d91sm147214345e9.17.2025.11.03.02.14.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164849; x=1762769649; 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=hhmyK4oEIpSWjXpku9unHriewKy+XN/2ZADa1rxHLbo=; b=dpN9WfvGd09DT3LiiUHQce1eN+9ZRzVhXa9Y25Yb4dCVr1lwORgKAFwQznrwvOtWjo NOtBFu9s6oFkWDcC6Wo7FyGrL0mXWbmlAXuW0q+DZv2jH+pezuuqP25gTIXDdmaAvYYp UDrLYD/FYiDjT/QTNBZmxOm31BIXgjv6QzbPgpsBGPW2QAQA/Liln00IuXP18rTKPGqH zbBWlAQ5O0xNSqBu97QtkvDh0Y+T8lTEZrT7rSSybWE51suh2GxQ5g4jgjjZHDVxQp6j dqOe8gqnsUVVDh1Zo7cG1Yw3U4gafHNB/fFgo/b49I7Ic4dtEv6JlFiDFvu9qis11BNO u9Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164849; x=1762769649; 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=hhmyK4oEIpSWjXpku9unHriewKy+XN/2ZADa1rxHLbo=; b=qhmvF2mp3nY2D/D1HZvpUovVLUJncPXtudBYL0ocum04xgAVY0mO3QSifW9zeQcKrn EGeyydqh57dWjMu7n+AbPMbomOxVsD5/etY0v8sNT+c7aG2kdP7vLb9VmwzXgnWjbH2c tr+sZ/OcssfFhKAmmABlIWh0o2Xozx7oYvb/VkRaPUzoYtr+/bxUQ0N9xJ/dKIFTXzJj tSuwb/IcJxX3VFG/9b+iaGh2x/fxZx6RcbCX9smuRuw71s3FV6EunUC5Gov6x+prCa1A XizYusDUJeHGAD3DSJp02QxRTZrGAYExrj+g6QUYLmQrX9ZXsJY4110hOCP6tBJFkoqq 0hrA== X-Gm-Message-State: AOJu0YwOOPJpR57GX5uTWt+UqViFACVQ0GC+J5+R3OUfYmngZAZJhUAe o0FEgnk7E/6mCBgwmJfpQrBrBQ0DYNTsivKp8Ixu1unSYFESdBruuEt0c/K4uNF5/EiKupcC523 Jotmyayc= X-Gm-Gg: ASbGncudbxYvFOTAxpyfhGCcCF9o82OUi4Ivm5THTbsAe0I4dX6uwpCb1xs14Zfr9Bv TLx+VX6+Y41+W+0LutoScF2JmSU9Ykx8K9xOQOTQoHnMrpuAIMLxDJz77GzBvjVe372oLN32RjB xku4T4iFOs0DHuuiijnUHfmE19fL1gfH/1awSvEVXLvjt03+MCLGWUBjvM/uq0vCRCu2Ts6IjF2 XAwjMRzIa7MOLiXBb74ZNEiTuvazT6iuFQvABoF4WhIlN6SDT/E/IqAloIp/4pn/1ilC5j30vgW 1GwnAks4kGFpxmh0nBdQSR/pVezeNZreIw2KRUzKBlIv4jcElcQrC0fEmwpB6+dmE85jnSSQF5j TS4e4aTsfNLpyjMGhEb/Wcce9wNQjexVdmSKnMM9/R6vlj2Prf/bARY5oVhuLwWifqZFHZaJVmc Cs/qPuX2LdaCEKjPa8o/46fWUh1bKzmjvMShXw5vaB8r2LjgahFaJCXIBmDXE= X-Google-Smtp-Source: AGHT+IHBSr31da1TwutqIu8czWMLdsq8PZHoB7esZKvm/GO3vd2GN0EgTC9gtfSBf2Eq4K6O+eHExQ== X-Received: by 2002:a05:600c:358f:b0:477:25c0:798c with SMTP id 5b1f17b1804b1-47730175fcfmr133189035e9.20.1762164848706; Mon, 03 Nov 2025 02:14:08 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 08/23] accel/hvf: Simplify hvf_set_phys_mem Date: Mon, 3 Nov 2025 11:10:17 +0100 Message-ID: <20251103101034.59039-9-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164919593158500 From: Richard Henderson All of the complicated parts of updating the address space are handled by address_space_update_topology_pass. Do not create or use hvf_slot structures. Signed-off-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/hvf/hvf-all.c | 111 +++++++------------------------------------- 1 file changed, 17 insertions(+), 94 deletions(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index f203a6251f0..76b8d4d4068 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -87,45 +87,16 @@ void hvf_unprotect_dirty_range(hwaddr addr, size_t size) HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC); } =20 -static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags) -{ - struct mac_slot *macslot; - hv_return_t ret; - - macslot =3D &mac_slots[slot->slot_id]; - - if (macslot->present) { - if (macslot->size !=3D slot->size) { - macslot->present =3D 0; - trace_hvf_vm_unmap(macslot->gpa_start, macslot->size); - ret =3D hv_vm_unmap(macslot->gpa_start, macslot->size); - assert_hvf_ok(ret); - } - } - - if (!slot->size) { - return 0; - } - - macslot->present =3D 1; - macslot->gpa_start =3D slot->start; - macslot->size =3D slot->size; - trace_hvf_vm_map(slot->start, slot->size, slot->mem, flags, - flags & HV_MEMORY_READ ? 'R' : '-', - flags & HV_MEMORY_WRITE ? 'W' : '-', - flags & HV_MEMORY_EXEC ? 'X' : '-'); - ret =3D hv_vm_map(slot->mem, slot->start, slot->size, flags); - assert_hvf_ok(ret); - return 0; -} - static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) { - hvf_slot *mem; MemoryRegion *area =3D section->mr; bool writable =3D !area->readonly && !area->rom_device; hv_memory_flags_t flags; uint64_t page_size =3D qemu_real_host_page_size(); + uint64_t gva =3D section->offset_within_address_space; + uint64_t size =3D int128_get64(section->size); + hv_return_t ret; + void *mem; =20 if (!memory_region_is_ram(area)) { if (writable) { @@ -139,69 +110,28 @@ static void hvf_set_phys_mem(MemoryRegionSection *sec= tion, bool add) } } =20 - if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) || - !QEMU_IS_ALIGNED(section->offset_within_address_space, page_size))= { + if (!QEMU_IS_ALIGNED(size, page_size) || + !QEMU_IS_ALIGNED(gva, page_size)) { /* Not page aligned, so we can not map as RAM */ add =3D false; } =20 - mem =3D hvf_find_overlap_slot( - section->offset_within_address_space, - int128_get64(section->size)); - - if (mem && add) { - if (mem->size =3D=3D int128_get64(section->size) && - mem->start =3D=3D section->offset_within_address_space && - mem->mem =3D=3D (memory_region_get_ram_ptr(area) + - section->offset_within_region)) { - return; /* Same region was attempted to register, go away. */ - } - } - - /* Region needs to be reset. set the size to 0 and remap it. */ - if (mem) { - mem->size =3D 0; - if (do_hvf_set_memory(mem, 0)) { - error_report("Failed to reset overlapping slot"); - abort(); - } - } - if (!add) { + trace_hvf_vm_unmap(gva, size); + ret =3D hv_vm_unmap(gva, size); + assert_hvf_ok(ret); return; } =20 - if (area->readonly || - (!memory_region_is_ram(area) && memory_region_is_romd(area))) { - flags =3D HV_MEMORY_READ | HV_MEMORY_EXEC; - } else { - flags =3D HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC; - } + flags =3D HV_MEMORY_READ | HV_MEMORY_EXEC | (writable ? HV_MEMORY_WRIT= E : 0); + mem =3D memory_region_get_ram_ptr(area) + section->offset_within_regio= n; =20 - /* Now make a new slot. */ - int x; - - for (x =3D 0; x < hvf_state->num_slots; ++x) { - mem =3D &hvf_state->slots[x]; - if (!mem->size) { - break; - } - } - - if (x =3D=3D hvf_state->num_slots) { - error_report("No free slots"); - abort(); - } - - mem->size =3D int128_get64(section->size); - mem->mem =3D memory_region_get_ram_ptr(area) + section->offset_within_= region; - mem->start =3D section->offset_within_address_space; - mem->region =3D area; - - if (do_hvf_set_memory(mem, flags)) { - error_report("Error registering new memory slot"); - abort(); - } + trace_hvf_vm_map(gva, size, mem, flags, + flags & HV_MEMORY_READ ? 'R' : '-', + flags & HV_MEMORY_WRITE ? 'W' : '-', + flags & HV_MEMORY_EXEC ? 'X' : '-'); + ret =3D hv_vm_map(mem, gva, size, flags); + assert_hvf_ok(ret); } =20 static void hvf_log_start(MemoryListener *listener, @@ -260,7 +190,6 @@ static MemoryListener hvf_memory_listener =3D { =20 static int hvf_accel_init(AccelState *as, MachineState *ms) { - int x; hv_return_t ret; HVFState *s =3D HVF_STATE(as); int pa_range =3D 36; @@ -281,12 +210,6 @@ static int hvf_accel_init(AccelState *as, MachineState= *ms) } assert_hvf_ok(ret); =20 - s->num_slots =3D ARRAY_SIZE(s->slots); - for (x =3D 0; x < s->num_slots; ++x) { - s->slots[x].size =3D 0; - s->slots[x].slot_id =3D x; - } - QTAILQ_INIT(&s->hvf_sw_breakpoints); =20 hvf_state =3D s; --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762164977; cv=none; d=zohomail.com; s=zohoarc; b=T4h97lN5zVw5FQCikRqAAfNtfNGYcCaHcSTrnNop95wcpGwC6068fzEBc/jslffkNnKTL+NqeIaVaUsMOkipBowYKyHGr8yRCxK61sjY/LtrOGXmcxZRc9651TI3esnGXYyRIbX6gwiE1FqoEVHEBSMBA/kQcP7qqaJKf5/2DTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762164977; 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=c57WLejTczCDPIZIT4ByZo9teKQW5zfA4LdyJABPRTg=; b=X8HE6vYB/zAPbj6BruSelYuv3+DlGeBXM72h0znPAxcFOSaZugRKYTNAbo0IJRJhT0zCmWNgaVNs8XmhiBbj97ohPlOFHppqiurg2EHtdA7c2pGSJbeiym4s4A/yQG4axR7cXMmljD8Q77aPq0hAPXQokjzPhf04d/luNA93kf4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762164977438659.2250772814823; Mon, 3 Nov 2025 02:16:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFraK-0006dY-MT; Mon, 03 Nov 2025 05:14:49 -0500 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 1vFraG-0006Tw-Et for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:14:44 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFraB-00033m-9J for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:14:43 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-429c82bf86bso1631240f8f.1 for ; Mon, 03 Nov 2025 02:14:36 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c11182e3sm19869172f8f.11.2025.11.03.02.14.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164873; x=1762769673; 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=c57WLejTczCDPIZIT4ByZo9teKQW5zfA4LdyJABPRTg=; b=EL+kTxskJNIOFprVuMUOo4cBwehT2S5s7PRmOnAGr1QqHKhlC5nv7do9AatoeZFcLL sk8uhKGA/i7OBuwh8CK6ng4tB0t3X4MIJcX+HydLxGPdng4RpsXjrsZA3g4ReNbBUvVT FOKUHw23+VJD9hcgCVeOShlb3SjSB5QxuSPQ8/jG5200qCOv8a0fVpufwpGofItkoLpJ OR+aZz0ok8lMOm9qluNltpx9j3rhJWmUPdYMe183Sg0kf5pO05nnf/Lekfj0/LZ39mIo iB9xieErpbw6lLfPrZyjkbCF2Z+VbOGJcuw2rP+TbSMGTn/4gsla5dSredbH3QTJmm3w 6OdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164873; x=1762769673; 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=c57WLejTczCDPIZIT4ByZo9teKQW5zfA4LdyJABPRTg=; b=czD8b7seEgJ2bmk7FtDFOxKC8SAR+0H9KbryDcSinzr1pA8s2miQsCRqULKnWXDxc3 ofAjiS+wUSkiYr7aNof5JBOwkVPDyK6Mo/OzJlRKRpfjbdhba3K6OxIXxq33+wR9c6C3 1+yrr7Z0SIKK8B25oeX2hSmlL5bkrosqhDn9oSdfx2W3M261RS6pwaUEothAAEkNJLjK fzYFqMjB59tIt6m0jC9T9rzob32T4Wm//9bUd2UsBETsaoXC4icUDTFzE+7TWSXpdfzi 5bmYjVxs6YuXkuU2+1rVVdKWyzLtoNB1+MGNm5wa63SJh3ZhFa9tqvuJ5/gqI7hol8SW zIrw== X-Gm-Message-State: AOJu0YyfPCzwqdxtfwxbmKBbOyAME8sT3wn8vak+ca3sFpqIt2PGrJou wBZOXO/Gm9RAMufSuHmgb/w+ZeeyAeiLLvJrJlS3PdVhp+y/Cagq9+tq/z5pkKRX+IGYpNf3eG0 2FLaSsQQ= X-Gm-Gg: ASbGncs0N/5u82vqFAaxHa6xIU7Xq7pPT2PrxsmP9h4Ly7s9yuU2afA0qCKW+/ulcwz WRUMhpe7hQk+b0d+LKPxzI3I5R2Xkmm0RCmqaCaz6jOPouM9fI9qn87CJHLyU9Kw1/TQ9nwU0Ai DPKprgA7rJ3PCB6ORAUxWvBWMzL/rj7CsQzNMqFkBg1VNoIEBiXHfxSe1l2gAkaLv/kSX31BkIt +lC4JwgKVHQg5Hz8Yr7lIqM1STKmh5+phYtDklOn6vpd9FzyAybr/WlG6M0rvv5iSjIxpT8eP/F aK5nHywfOiHMdAx4JC4IDDUhthn+TWA86nlyk9svSXSKdeAJrlhtLMRjbIpDy2uNLmTRKFk2KiN b1rxeSjvWNNgraviBkQUucDQgvcTwlXaQT58LU+QEiIqukv90rDH+04k1XiOoiDHvBzeI6xTpSa rNCn4LkopZl8++llfzVOf+Xj97zgmovsF0l1BQ0/88InW2i9dbnA3WjmkRnJM= X-Google-Smtp-Source: AGHT+IFNM//af+kU4SVUq3YIQ7Pdv0I8MFFAY6t26nglj2Kg/iaETdq9BfD/XJqFue8hAbPWKrGQJA== X-Received: by 2002:a05:6000:26c2:b0:429:d41b:9fd8 with SMTP id ffacd0b85a97d-429d41ba2e9mr1711762f8f.20.1762164873082; Mon, 03 Nov 2025 02:14:33 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 09/23] accel/hvf: Drop hvf_slot and hvf_find_overlap_slot Date: Mon, 3 Nov 2025 11:10:18 +0100 Message-ID: <20251103101034.59039-10-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762164980389154100 From: Richard Henderson These are now unused. Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/system/hvf_int.h | 13 ------------- accel/hvf/hvf-accel-ops.c | 14 -------------- 2 files changed, 27 deletions(-) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index ee7ab689f45..d842d4b2b99 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -24,15 +24,6 @@ typedef hv_vcpu_t hvf_vcpuid; typedef hv_vcpuid_t hvf_vcpuid; #endif =20 -typedef struct hvf_slot { - uint64_t start; - uint64_t size; - uint8_t *mem; - int slot_id; - uint32_t flags; - MemoryRegion *region; -} hvf_slot; - typedef struct hvf_vcpu_caps { uint64_t vmx_cap_pinbased; uint64_t vmx_cap_procbased; @@ -45,9 +36,6 @@ typedef struct hvf_vcpu_caps { struct HVFState { AccelState parent_obj; =20 - hvf_slot slots[32]; - int num_slots; - hvf_vcpu_caps *hvf_caps; uint64_t vtimer_offset; QTAILQ_HEAD(, hvf_sw_breakpoint) hvf_sw_breakpoints; @@ -70,7 +58,6 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file= , unsigned int line, const char *hvf_return_string(hv_return_t ret); int hvf_arch_init(void); hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range); -hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); void hvf_kick_vcpu_thread(CPUState *cpu); =20 /* Must be called by the owning thread */ diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 3e5feecd8a7..bbb0b385fe9 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -64,20 +64,6 @@ HVFState *hvf_state; =20 /* Memory slots */ =20 -hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size) -{ - hvf_slot *slot; - int x; - for (x =3D 0; x < hvf_state->num_slots; ++x) { - slot =3D &hvf_state->slots[x]; - if (slot->size && start < (slot->start + slot->size) && - (start + size) > slot->start) { - return slot; - } - } - return NULL; -} - static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data ar= g) { if (!cpu->vcpu_dirty) { --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165027; cv=none; d=zohomail.com; s=zohoarc; b=hib80gtEIMxwj1FfQbaWtF8WG7Omsr2nYkaENj7BboDaeGdfa3gf8f4Za229rRnxTv8Lmf0ZaAiXFApJwjbkJHQ+LhkjnLOCjrSvb8nZV6JbMJBJMPlvj+XFc04uBk8J4RB6TKbR2WCc1pE/tHAv9N3rJeqdV9+ZRFf1+HWubLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165027; 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=SwbaDBH3uop6eLfaqXGIAXVHT6IrJiklTC3nfwY6u3E=; b=l4tin7LPb2xNyo3KIpV7yOtsE9pAwDi5pRXoz8kQSdmLjZINRKxYfF4DcdxZji+ydpXfaCO+QLF2UrFZ1zW+f1r3r8SOd/s2ADWbXb8xMfcxOfrNztNweceEx60yCplJJxONUY8ke737qRDjZ5GhFPG/JejQkPs/iAxgkfVEQUc= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165027254886.9957591378304; Mon, 3 Nov 2025 02:17:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFraj-00070H-DD; Mon, 03 Nov 2025 05:15:13 -0500 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 1vFraf-0006y6-Gv for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:15:09 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFraX-000359-Eb for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:15:06 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-429c19b5de4so2237696f8f.3 for ; Mon, 03 Nov 2025 02:14:59 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c140629dsm19505975f8f.46.2025.11.03.02.14.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164897; x=1762769697; 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=SwbaDBH3uop6eLfaqXGIAXVHT6IrJiklTC3nfwY6u3E=; b=VYdbUOlY2q5a9jb+mPXi8RCoXOLOu3UEs7TSf366+WuPCUvDetaW6hEnTyPpTAuuzt zhLpc0HRs7b5Neca20wxg0xMp0FUy1Gz4gdqsSM3X2pnV6V8JnOHWsmCXCmYKLKFmiYK TkESUSIQL2y42YhhU2NwE5I1GqYLnHeCKxWdAw25mcHd2VU0+cp4Rf8V0ivt7oeX7V5O fJstPR7WEGjEyNMF5VBwXqZBP05FOjRO/B5SAcdGMrOt3nY3WG+uvOEyr38VcFI6pTnc C/KNrIlTGKRsMg7VY4CwGb9RpV6TK6NqTCDentI/tgGqkmlyw9Ogb45pui3Fc5AiOEQT gx+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164897; x=1762769697; 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=SwbaDBH3uop6eLfaqXGIAXVHT6IrJiklTC3nfwY6u3E=; b=qYfAIGwh8BGdEFXnKK1SAmaizmD5ucbKRfxrXZk6TM6ZqJc40sdMTNBU3AW5G0GbtO 5d+Zix/SA5lqh1ciUFftrjeoBCqldLy2eYEEOu/DBTXOFKVnmKyn+GDo6wGhvCVTU4Rx b1h0IUFm60olKKBzpYcAlgkEWdJcKV5k0CqUTK8vNjHwS8mTaPP/rrECC94LKtPqZAkP G283uECOUnTEy17RHgWTYR+P8zxvDYfya2D7uAUDbnldNGEJwHjr9WISJ3wo5O80yKbl vel8Zf43r6AzupxthGftItjGJruaq9n2zbGKa9GgFx8uXkWaS/2JB55GP1xYIPKZDZpI /WFg== X-Gm-Message-State: AOJu0YzCneMR6ewg6fsANo/eublPauv9jWICLdDeptMq8We+Boj1bIbu lKf3FQyz92xpbDJ56CgkkCpuT7gM2+ZZMbOJLHnBN1JAJuIM28zgwbioonc30n7UppqnCukM4rY jMBsxPFU= X-Gm-Gg: ASbGncu/ezQ15pOyzrEV0dTxILxOgLyjOg+1n5T6RBf2EhPMIk3izPc/5byGHCIyADq ZZLQxOxYzqoLBR9WaJao3NnkA4aUNDXPio+rxfbH356bImuIe4kqceFTHa7MzoZinDanBsj6dZX ZlLT+w8qIqKRCsTW94xEzdaVarCtgSUlxDja6l6aI+QostCg0bNOcGxdfh0PMhkJBiY4zHJ/g35 5gMAb6HK11WwbmcFvO2wTZk+fRpb8JscMHRhmideQ6/mhwIK7pc9tL6GaFXWV6MoeNOZfPFPtpM QDYIFj8hhMnzMsTdGHjp3lKmAQ3NVK6yRUpNaX6d+RPHK/1Tzsx/0W8zv+513zIcjwpTvUxD47N mlf5spRyIa/4ghX1KZOMh4pPMLu+mw3xrYoGET/yVPrhTFv0Hwd3iKV7MZMH4G8865nxXM3v6Fc p0ULTjGDr6Qh9R3ZdJQgUhe2ctuI3ucRmm8k4uk2BJRm7lPolOJ0woSYyRaS4= X-Google-Smtp-Source: AGHT+IHHcOWqv+uwo+HmK/GL3fNrGaXs9ETNHTZr9sAG2rAvYdwvB1+00WCsAe6B4i4d3ZEq2+WYaw== X-Received: by 2002:a5d:5f50:0:b0:408:d453:e40c with SMTP id ffacd0b85a97d-429bd68774bmr10767807f8f.25.1762164896903; Mon, 03 Nov 2025 02:14:56 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 10/23] accel/hvf: Remove mac_slots Date: Mon, 3 Nov 2025 11:10:19 +0100 Message-ID: <20251103101034.59039-11-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165030266154100 From: Richard Henderson This data structure is no longer used. Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- accel/hvf/hvf-all.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 76b8d4d4068..cbd0858b763 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -22,15 +22,6 @@ =20 bool hvf_allowed; =20 -struct mac_slot { - int present; - uint64_t size; - uint64_t gpa_start; - uint64_t gva; -}; - -struct mac_slot mac_slots[32]; - const char *hvf_return_string(hv_return_t ret) { switch (ret) { --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165062; cv=none; d=zohomail.com; s=zohoarc; b=m/KthaZ4drxOWF/vuVIxeLx3mAKDdsmSefSvrK7jlxSo0ReTM3rR8TxzSZqMOCnMt7+byihO8apw+gsLmP8ypRLMJsyWS/BMcvcs7aCHCZhS3++rN241Ji04YWaPw9H5rZrNSjwsyaajimGK3G0ZTid5PzEnGkaSO+xyqvoTyw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165062; 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=4jVZL+EPfNSiEcUqc0mMtti7iz45SaUWfxueOvD5pC8=; b=GS6M1ybCQeQfgtgClhuu3Q5ydEVbAGwaiCtJg9y1Cf+z14SU2Y3rEbkcg36HzITDwT5c+IC1uZcHvAg1NUMTH/4FGDh/0u66hj1yQPCQvW04Hk2Hfj+6lssZHeGMGol5V31kRkhFnpyNZcg1SvdOiUyZnPzOfyHYwdN4nb61FNU= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165062706534.3836940240028; Mon, 3 Nov 2025 02:17:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrbA-0008CZ-FA; Mon, 03 Nov 2025 05:15:40 -0500 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 1vFrb7-000828-Ho for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:15:37 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrb2-0003LV-Tv for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:15:35 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4710683a644so33123855e9.0 for ; Mon, 03 Nov 2025 02:15:29 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c394f0csm145356445e9.16.2025.11.03.02.15.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164927; x=1762769727; 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=4jVZL+EPfNSiEcUqc0mMtti7iz45SaUWfxueOvD5pC8=; b=tAzf9P4EjRPgLr8FVv1hca4kjM2As4clwhcmFcDAu00WpEGfuqjRCI9h6H85mCSdXd Lz7uMkVGZAy34QNytbvuQMqWI+EMGWLmSGQ3+d1ZRmyPQO/oqO0biZGhJEqQGxW4go52 tcXZFd7sqC++mlpLtxlFyZB13p61wGmpS6pgd4a1VyVvvnWkrvRmUYRJQXYHX9IlS8bb g4fcHPI4OJzDCuKXjea21rM/vnhESPtSv1jRyhtXlWAvCQmi4Yoyhb9YEp0LMwD9yk4Z XN/xM7v2nEs70jGhXQmaZw2S2M3z9LBHX4ktj0gAZ2O8yqy5XYYbMAMOMB1ujGmrC3sF DUAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164927; x=1762769727; 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=4jVZL+EPfNSiEcUqc0mMtti7iz45SaUWfxueOvD5pC8=; b=diQ96upO3nZx0qOX5dvhzhxkC7WNZBvERST92oIuEr7vpzHJs31oz62aJPuuhdXrfu p5rTY3xwX0evSCIYMgMqDwGRF8PrAzLHhd0zux6r7KlM/PyVdyBMnsyRlXA2zkBTyh3L sm0yitrGv03zGAXJUpnYnihlJ+bY7C1Fw5QwFF5gQtwzHTyUZxRpuRX1/hFlF2PeDb5b Rvh990JYtj/PYtS8ipxIEDi8yjiv6Wzt2M2h+XDgMhrCQMvczB4+59PfqY7q0sybiwzg 3W6JNzWlOgMQ8Sm88XEuGVQmyS6LVp4ywoXWrXd8FO8AThvM2TZWT3MhOni1YMa+u6zO tYdg== X-Gm-Message-State: AOJu0YytGH3SDnrPu1XQNHwMkksQ78jite/oT6KMIPInBnQaQRhShsLv Il87Z828DLUbPuzZsjnj01MdEFkUquk0Ifql1T8fxfYiZDP88X5YTwBx7hKe35nVID9mzBsT1+O U/IcLfA4= X-Gm-Gg: ASbGnctrXQNaDK3bLkdIQ2AkZIWtJ210CNjAQOnI4JtHy34+RxsGagePax5bX97CqHW TCLiH4BFWwIE85en15YxAV/bkoJF5OIc7ePYdAdNJdiWClRvQLBATK+MrG1VtYBHKq2GDz/7I5Y iJb4ON8OuIqg3ORbX7vJgETtqn0rPhf0mQ8y9JhYqbqYJ2NUgcGjOC70p1Q9+hmZozot9YN4Zn5 NWzvVJHnhSTpNsj/0jo4VOSpqYuvjejc8fuNh6+f+4B/eDlBU9cWdHIW0m9FnP01EK46A6gNI7g IyPAPFjJ3rXm3Ne1rczWRQ8EgV3BHF9LnZKkyPuEA4d5k9g44GAInm+lxCd5esmJdJh4NbMj3/W impgjARwOSODBJJWHzHp53r78ntnsbauvcH0V577LGtfakWps9ReJwR7GrjnAN9SLWGo9kG27Eu 2MMebUGO/NwsjqGlmdevh4q0rrA4upFe44qnZjGGB9lPEBaw5Yh+RjolAo2vjKmQ/7ho3E6Q== X-Google-Smtp-Source: AGHT+IGduk51gM2vy9eDhtnuyyaB6zcePqGNY3tSTdUHZOPImWAYPDhGV/Bac1PijLJi9wQG36XOMQ== X-Received: by 2002:a05:600c:530f:b0:46f:a8fd:c0dc with SMTP id 5b1f17b1804b1-47730068201mr132385495e9.3.1762164927408; Mon, 03 Nov 2025 02:15:27 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 11/23] target/arm/hvf: Implement dirty page tracking Date: Mon, 3 Nov 2025 11:10:20 +0100 Message-ID: <20251103101034.59039-12-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165064621154100 From: Richard Henderson Notice writes to pages which are being monitored. Mark the page dirty, re-enable writes, and retry the instruction without emulation. Assert the fault is not from a stage1 page table walk. Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 52 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index de1e8fb8a05..0f584b8137a 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1869,9 +1869,10 @@ static int hvf_handle_exception(CPUState *cpu, hv_vc= pu_exit_exception_t *excp) uint32_t srt =3D (syndrome >> 16) & 0x1f; uint32_t cm =3D (syndrome >> 8) & 0x1; uint64_t val =3D 0; + uint64_t ipa =3D excp->physical_address; + AddressSpace *as =3D cpu_get_address_space(cpu, ARMASIdx_NS); =20 - trace_hvf_data_abort(excp->virtual_address, - excp->physical_address, isv, + trace_hvf_data_abort(excp->virtual_address, ipa, isv, iswrite, s1ptw, len, srt); =20 if (cm) { @@ -1880,23 +1881,56 @@ static int hvf_handle_exception(CPUState *cpu, hv_v= cpu_exit_exception_t *excp) break; } =20 + /* Handle dirty page logging for ram. */ + if (iswrite) { + hwaddr xlat; + MemoryRegion *mr =3D address_space_translate(as, ipa, &xlat, + NULL, true, + MEMTXATTRS_UNSPECIF= IED); + if (memory_region_is_ram(mr)) { + uintptr_t page_size =3D qemu_real_host_page_size(); + intptr_t page_mask =3D -(intptr_t)page_size; + uint64_t ipa_page =3D ipa & page_mask; + + /* TODO: Inject exception to the guest. */ + assert(!mr->readonly); + + if (memory_region_get_dirty_log_mask(mr)) { + memory_region_set_dirty(mr, ipa_page + xlat, page_size= ); + hvf_unprotect_dirty_range(ipa_page, page_size); + } + + /* Retry with page writes enabled. */ + break; + } + } + + /* + * TODO: If s1ptw, this is an error in the guest os page tables. + * Inject the exception into the guest. + */ + assert(!s1ptw); + + /* + * TODO: ISV will be 0 for SIMD or SVE accesses. + * Inject the exception into the guest. + */ assert(isv); =20 + /* + * Emulate MMIO. + * TODO: Inject faults for errors. + */ if (iswrite) { val =3D hvf_get_reg(cpu, srt); - address_space_write(&address_space_memory, - excp->physical_address, - MEMTXATTRS_UNSPECIFIED, &val, len); + address_space_write(as, ipa, MEMTXATTRS_UNSPECIFIED, &val, len= ); } else { - address_space_read(&address_space_memory, - excp->physical_address, - MEMTXATTRS_UNSPECIFIED, &val, len); + address_space_read(as, ipa, MEMTXATTRS_UNSPECIFIED, &val, len); if (sse) { val =3D sextract64(val, 0, len * 8); } hvf_set_reg(cpu, srt, val); } - advance_pc =3D true; break; } --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165045; cv=none; d=zohomail.com; s=zohoarc; b=YN+7cUNTosP/14O2qbgn1RVzW9Ww5iRQZ5Xmw6coe64hJEscU6r20eJtTJbCzTa5ICkkwaiKoXCBnB4MBx8FHZsVGHsVtKtZBOSjJjoaiZywWuaeMY0P9iVZUKeeqSNhlwVFkbqqlX/A0m6Z+32dxgayAMlchi/oaC2cBxBAlV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165045; 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=4UXacg8QXXqCJVu+ViWlRptMSM7MqADu/UIOis6wkvM=; b=O6DFXNv7XYaDCoEscyiPqxKFzwne1tQBO3HBLl5oLx2Vl2x2wU6DIPynvzpSayp+1JL1iHCofdHzbccthKOGw6CRQaYxA+MV/LIzlHWDcW/V3nTwiewmS95YkxfOerViXIkGCWICZj7efrQaQCwSTgSc/zER4FPiL4dPrC5kNGA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165045528449.6319655103266; Mon, 3 Nov 2025 02:17:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrcC-0000pH-7U; Mon, 03 Nov 2025 05:16:45 -0500 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 1vFrbl-0000cz-IR for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:16:21 -0500 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 1vFrbP-0003Pq-EE for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:16:06 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-429c8632fcbso1228441f8f.1 for ; Mon, 03 Nov 2025 02:15:53 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c2e6771sm145968775e9.2.2025.11.03.02.15.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164950; x=1762769750; 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=4UXacg8QXXqCJVu+ViWlRptMSM7MqADu/UIOis6wkvM=; b=u7CIgsrHmpWTRuey5B8ofIm99V8AcB6mcrAHHszY9g8NayRen3ynEHr2TfwqzzCu1c DMIaRJv1GHPJWfWu0GETxkjZ6ywsFTb/aOXdQxynPjJsCuy1YjT24WAUfNH/p/7ABf3S g8hwzjVFI6vx5mnB9cTvCouBUIuGTF2/lFYGY8uQyxrKo3aHZvxRYVX+dTRBsqJnhU/M LFhc5BZgNtqaGo94U9RIkfgr+9176wGaRhaPk1uBd1BNDwM54sfltSlCcBeyZOKN9SbW YFvNMOv1/QLZcT7Ev54y0oDKD5QJ9hfB/mP6M5D8cHMGkr9e1sa/yKAB58lKeTLWZv2/ FhSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164950; x=1762769750; 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=4UXacg8QXXqCJVu+ViWlRptMSM7MqADu/UIOis6wkvM=; b=I9doUDmIElYviHaWeDK3FcjROmzFoaAGR2BFp7nW7Q4jFVuwCD3p706oXfa39At84r rbSFV6bBVg1g1KRqm1slLXzDPuVnJ0rtuea0E2hBdOIP8dzGKOy8QyrRYKlwqs5i5N17 sbPFuwUxXf1IOTdRRB3nh+FnmE+5DrtTQDzSaC3vIRYgbwbzTg2dtRVaF2x54XEWAQny O5BVTWNXiMyNuy8mX0wF/8eZX5VPuZNX6Dooapi+uNs4pbhLNVrueQcvlZDWDn21hFzQ zSqA66b8+fZ4986xPWgXGz6OI09EdQI51Oe4jFIfCwJGJS2JqUwR9Yenr6K7wim8iAFK MVFQ== X-Gm-Message-State: AOJu0Ywlpq5ChohxycZdSsyLiRWnP0fk4/0hV3oIg/fcBwV0jCRzLS0R iODV/NOSXrLJRyxndPlMReriE+PkfbFL+LGFQFrtdV97tbzOFwEErsD+qbvAyV+V/v7YHBs+c32 QIIN32o/d7p90 X-Gm-Gg: ASbGncvTpkQUQ6DlrcQ2uY60leJphlIxCef/5RdyEERhP3lP41p+YT9UhMD+FYguts5 99D3m6PdBVyC3CSTMczb/JWEKUQF/hElBwBU7H4v7ceKregj4XnIpGvRqIs0rg/x/8FRrfrTZK6 BPrXvUWAgqQpBGrBhC/d+Ryo5711z0oYcxvwsHCNY9y2lnYtXhQ07XY3GEe9iOWS+gWlcnrh6wd 9zU73u4gwWnxNrRh15/LSNfFOxiN9kdBEjQYP5idcL+3/8+5YDOAupIJPOX0LL1uXwPRm7p9/s4 f9t6Z37i6OxsY0FFfKP5HnI/W0CxpVqhsfJ/fia4WGA9lOqo56XJZc0T/M+rD7rosOxQPve4q2l iadbcC/5EyPRx4ECFwOH0EQc291xigNn5AhgB1PEJ9xzPImBb4zihpA94w8dsF2eR8F3VpW1evm u9Z7EXHgvFvie+st4TNYIm/5Iv6oxBfidPmVFp7XlKyihbufTyNjIMtczqIBY= X-Google-Smtp-Source: AGHT+IEzM9ZamtMWij2/wVDfwjrebZuDC+xNtL+OXP2xUFNA/OaMg+jJYlkSrvup8esv2Xy+m7Xfqw== X-Received: by 2002:a05:600c:a39a:b0:46e:32d4:46a1 with SMTP id 5b1f17b1804b1-47730f93928mr75753195e9.22.1762164950385; Mon, 03 Nov 2025 02:15:50 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v4 12/23] accel/hvf: Skip WFI if CPU has work to do Date: Mon, 3 Nov 2025 11:10:21 +0100 Message-ID: <20251103101034.59039-13-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165048387158500 Avoid sleeping vCPU thread for any pending work, not just IRQs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- target/arm/hvf/hvf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 0f584b8137a..5e46e8bf4dd 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1737,8 +1737,11 @@ static void hvf_wfi(CPUState *cpu) uint64_t nanos; uint32_t cntfrq; =20 - if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIQ)) { - /* Interrupt pending, no need to wait */ + if (cpu_has_work(cpu)) { + /* + * Don't bother to go into our "low power state" if + * we would just wake up immediately. + */ return; } =20 --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165189; cv=none; d=zohomail.com; s=zohoarc; b=Z99q5E6hiFgrKpcNdWekMCFfMeI/HsBRek60bEnpU9s6Ixehd8nB0SXSYDBuIhk1T5mijXOhZACIxaX/Z2UpEKfXYgPn1fQiNz8FbmqdeDoknZ+LQXx5ztT0d6qp+hfReAWvsPh47i2fvl6UcrEgVv4SuSiHklSCYN8zwYTtJFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165189; 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=AHrIsc13n3k3WjZqe8R3WBdhQ7AP5c+oeQndZCxEU10=; b=AOYwzy5RJloRVX+f8pYVVpUYMRR4q5ruW/sZK/SfodSVGAOJJrO/x5h/8n46mrty6ebCmaNNluHDiJUo3HAM8QXQgBbLsIJgIC410vBiZb6/3b1Hhd1RI6/zx1aWV89G4ZgcilkwkOKGFzNZ9Fe60DranJe0riRJoyG2luxbAhA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165189775772.3169903519142; Mon, 3 Nov 2025 02:19:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrcF-00011Q-Sk; Mon, 03 Nov 2025 05:16:47 -0500 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 1vFrcD-0000t8-5P for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:16:46 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrbt-0003UY-4U for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:16:34 -0500 Received: by mail-wr1-x443.google.com with SMTP id ffacd0b85a97d-3f0ae439b56so2164686f8f.3 for ; Mon, 03 Nov 2025 02:16:17 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429d28f2d29sm6278844f8f.5.2025.11.03.02.16.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762164973; x=1762769773; 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=AHrIsc13n3k3WjZqe8R3WBdhQ7AP5c+oeQndZCxEU10=; b=dPnaqBO6d1NsZcuAdNMIyHy5raOQPqokiqEV/+7F3d+9bwJ5OPBrNmZMDAQgbDSAxD DxLZODMwfwJjlIWNOj9KjFscD0sASLfceBeZKo0Y2N0lfgsRUKD9PHD7m0ArE9FBlXyr kzC2Q4uWznUNG4dASgevGCeaIdYBnqpb2DERgfXj3QOj47RvqRwTCSbnDAdjSzlgx4ZY kPXAamA2Rb4NIwqoLD+qPID+4hnWHzrsS+u5vHlr0kH+DdsKcIvvthbVYWWBwfbVTxxN TjGfZ963ZmpfmjZ79x08vkJvo43OjMWXAx4ZX+WspoYBnG3JYKvIK6dHy3e8NKVWP5PF GMAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762164973; x=1762769773; 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=AHrIsc13n3k3WjZqe8R3WBdhQ7AP5c+oeQndZCxEU10=; b=RkhNge2IGaDpr2rD7rbYSP0n7+mQ0jhEXDXAf9G1Pys8g7KiCx5k8EQ8xa5DkE7G8I vEUFlgR18VbkK/TK63VuB8tfpEUz6HMG7pHvtQL7Iizvucym2VD12JH+Zgi5iXeLhgQj eu7MeCjDb1rvuLxKWrm1cJnuIVP6ZzPnzQCxsJ5kMyPPv9TZxXGZpK+Em960X/Q9Hyqn ZTVdPDCwxanOk+ilEhh3BEilZuvyviSnRr9li36efkyZ/7eSTjrcRVBLg/0baRQZwnwg abhXDccqMLTPMsoNFip7tidyo82a98QG3IvwxCrTprIyOmNL62DwLt4JtJGyT9CCYuaj JbsA== X-Gm-Message-State: AOJu0YySQrB+yrWjf1pzJ0Gd/qNm0Z0SOt9LmOOw9tCsIM5fH1tsZVVc yIGLK2YmomRcfxeXjHNiIpx0MNcmoEOowMfk7qbEbMqzeIbgrUXDM133CYyRHueNrgZRSHzMtAU M3qa6Xow49B3jWeo= X-Gm-Gg: ASbGncuvExP2/8a8b8/CfqmMmBHjFVVZc1mhqVxi9AyzSfrGYsxP/96ZdCLrVq2HiZ5 Optu03JTX9N1t3fOE36ah6OlHvdJiqk3jiwHIP0hXwlE4fMRVnshfmZS5lHcutWW89zj5ZPiSu8 X1A6dbNfFXW0eFSVVkqXwmyb1P7CjCsKvtl39C8c6lKWcurDeaWAciJm12xI+RDuocEys8G81me fdtsC2cv86RpcjU3hHQwndv4JTBbxdagQB58ABhGqm23/56Tk7Y8MQ8h6UdaKM1wYXKqEKZEr4p jVrHgWHLJzwVZmLuuOnzv1Mpq9kDY1MvxHvg1PjuK4gd3OsiAmRBC5pwdfvZ8YxMsFMxLU49sOL bU5FCTgFUEER23Nr6Iw2b1xmbBMTNIMTl2hDMjmi9IRuVEEkJUQA49Pje8EeFxICVubL2eKpeNP NbbcY1RzAiC5euvMlZ92EjCNKjHG2KkFu+Eqn8XExLdzZHVEbruJK1OzQEfCF5QwQBo7stQQ== X-Google-Smtp-Source: AGHT+IFtYf7L01WGLYzAQgeCtH+nZVWml9gap2cJyPcyAoNXDlq+U0WB7BTAujEU1IDg/6CpIFULlw== X-Received: by 2002:a05:6000:1846:b0:429:8c3b:c4e2 with SMTP id ffacd0b85a97d-429bd672378mr8281847f8f.7.1762164973296; Mon, 03 Nov 2025 02:16:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 13/23] accel/hvf: Implement WFI without using pselect() Date: Mon, 3 Nov 2025 11:10:22 +0100 Message-ID: <20251103101034.59039-14-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::443; envelope-from=philmd@linaro.org; helo=mail-wr1-x443.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, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165191475158501 Return to the main loop where we'll be waken again. This avoid a tricky race with signals introduced in commit 219c101fa7f ("Add HVF WFI handler"). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Akihiko Odaki --- include/system/hvf_int.h | 1 - accel/hvf/hvf-accel-ops.c | 3 -- target/arm/hvf/hvf.c | 74 +++------------------------------------ 3 files changed, 5 insertions(+), 73 deletions(-) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index d842d4b2b99..c8e407a1463 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -47,7 +47,6 @@ struct AccelCPUState { #ifdef __aarch64__ hv_vcpu_exit_t *exit; bool vtimer_masked; - sigset_t unblock_ipi_mask; bool guest_debug_enabled; #endif }; diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index bbb0b385fe9..5922eb02e70 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -134,9 +134,6 @@ static int hvf_init_vcpu(CPUState *cpu) sigact.sa_handler =3D dummy_signal; sigaction(SIG_IPI, &sigact, NULL); =20 - pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask); - sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI); - #ifdef __aarch64__ r =3D hv_vcpu_create(&cpu->accel->fd, (hv_vcpu_exit_t **)&cpu->accel->exit, NULL); diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 5e46e8bf4dd..51fd8c7175b 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -301,7 +301,7 @@ void hvf_arm_init_debug(void) #define TMR_CTL_IMASK (1 << 1) #define TMR_CTL_ISTATUS (1 << 2) =20 -static void hvf_wfi(CPUState *cpu); +static int hvf_wfi(CPUState *cpu); =20 static uint32_t chosen_ipa_bit_size; =20 @@ -1703,81 +1703,17 @@ static uint64_t hvf_vtimer_val_raw(void) return mach_absolute_time() - hvf_state->vtimer_offset; } =20 -static uint64_t hvf_vtimer_val(void) +static int hvf_wfi(CPUState *cpu) { - if (!runstate_is_running()) { - /* VM is paused, the vtimer value is in vtimer.vtimer_val */ - return vtimer.vtimer_val; - } - - return hvf_vtimer_val_raw(); -} - -static void hvf_wait_for_ipi(CPUState *cpu, struct timespec *ts) -{ - /* - * Use pselect to sleep so that other threads can IPI us while we're - * sleeping. - */ - qatomic_set_mb(&cpu->thread_kicked, false); - bql_unlock(); - pselect(0, 0, 0, 0, ts, &cpu->accel->unblock_ipi_mask); - bql_lock(); -} - -static void hvf_wfi(CPUState *cpu) -{ - ARMCPU *arm_cpu =3D ARM_CPU(cpu); - struct timespec ts; - hv_return_t r; - uint64_t ctl; - uint64_t cval; - int64_t ticks_to_sleep; - uint64_t seconds; - uint64_t nanos; - uint32_t cntfrq; - if (cpu_has_work(cpu)) { /* * Don't bother to go into our "low power state" if * we would just wake up immediately. */ - return; + return 0; } =20 - r =3D hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CTL_EL0, &ct= l); - assert_hvf_ok(r); - - if (!(ctl & 1) || (ctl & 2)) { - /* Timer disabled or masked, just wait for an IPI. */ - hvf_wait_for_ipi(cpu, NULL); - return; - } - - r =3D hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CVAL_EL0, &c= val); - assert_hvf_ok(r); - - ticks_to_sleep =3D cval - hvf_vtimer_val(); - if (ticks_to_sleep < 0) { - return; - } - - cntfrq =3D gt_cntfrq_period_ns(arm_cpu); - seconds =3D muldiv64(ticks_to_sleep, cntfrq, NANOSECONDS_PER_SECOND); - ticks_to_sleep -=3D muldiv64(seconds, NANOSECONDS_PER_SECOND, cntfrq); - nanos =3D ticks_to_sleep * cntfrq; - - /* - * Don't sleep for less than the time a context switch would take, - * so that we can satisfy fast timer requests on the same CPU. - * Measurements on M1 show the sweet spot to be ~2ms. - */ - if (!seconds && nanos < (2 * SCALE_MS)) { - return; - } - - ts =3D (struct timespec) { seconds, nanos }; - hvf_wait_for_ipi(cpu, &ts); + return EXCP_HLT; } =20 /* Must be called by the owning thread */ @@ -1967,7 +1903,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcp= u_exit_exception_t *excp) case EC_WFX_TRAP: advance_pc =3D true; if (!(syndrome & WFX_IS_WFE)) { - hvf_wfi(cpu); + ret =3D hvf_wfi(cpu); } break; case EC_AA64_HVC: --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165182; cv=none; d=zohomail.com; s=zohoarc; b=edWn5PLtX5o+UbnG3P0SyBSWgf+vbKtlQfbFFFVzau6WKu1Wnu1bYxMR4O/13izF25BD4HLYc56FrxV6uBqTRngN4SJtk5z/A9Hp0G7RKVoE5/T2UFiDQsFHjsDE2EFVY/gA8S9jMj6RPs8OwTsF3+Ar77Vs7LHAXHS+jeVpzaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165182; 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=REj67eGgPV90SX9WQX5yE1JHREa2u08WkjMgsUYxfus=; b=nBIcl88PaccP8ZHSiDd6/WWPCm/IkdKE+O6Kk2wM/VS7G130O8AHPeOYc8aMELlaaSXzQ/dRiBAkkgsOHjGuwM9GMTbgLLhldd+5gPeEYyxvOTDlSp2IL+kHNKx1tY5m5vVr9WfxzEZi6vxz3QSb6GPbbMV7lWBqxVdYdwU/fcA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165182897131.34029772803115; Mon, 3 Nov 2025 02:19:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrcW-0001eq-JD; Mon, 03 Nov 2025 05:17:04 -0500 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 1vFrcU-0001aA-IT for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:17:02 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrcL-0003ZK-Qv for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:17:02 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4710683a644so33137305e9.0 for ; Mon, 03 Nov 2025 02:16:49 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429cab8575bsm12193533f8f.31.2025.11.03.02.16.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:16:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165006; x=1762769806; 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=REj67eGgPV90SX9WQX5yE1JHREa2u08WkjMgsUYxfus=; b=PEjclthLw9SJRtvXsVS6RRdiDOtuoAODTrUwAjJ4L3g33IFJEhjLowExIg4iGW3Bd1 gLzzrj9Yb4HaWuwUQfF49MY9qC6z8zyo8xS+PFzkLQyYWQF3r3kdDlZls0xNkGEP5fOV 4+VzsH1vK9K3PsK+NpOlBt9uKmS+cppBsQVz6bBnxQyGwIeMgVyN4gRtS0T19NxcwEnE wulufDOi1bSCokgfW00XajO+pjOCpAVII7Cu/MA6mJk/Fhfat7MhvL08f++49Hcsfi/d j+c6SalF9cIXn34mHN2uWG5wYZflxCreEhLSqR3/xqqaoKexIjooLokTq6TAevJbHeIi gFUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165006; x=1762769806; 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=REj67eGgPV90SX9WQX5yE1JHREa2u08WkjMgsUYxfus=; b=ZBL1X73VFmlQH0J5U+7mkhK25mw+2sDxbHNu3m/Xk2ML3gMRP4wEcIpjo2fC+JNRj/ zxacPOdGiakSHseNCAc9U+JYFawzc4RyR5gJ4bF1x74qTiT5rghYpV0NT78Mpx1ri0Vz /cqn8F9BVGhLOhNzLO983ooIaj4OIAMiOQeuySY2E7g31mY6w6JO9/G27knG4ANT9XTN /BCaGse68pXodh/NFNte//Sl4RCSdQyq9LsOVI639p/L/BMMV3HZfiJhbrjE7R8a8quF 6Ah7mBKXidxR3/IedV2W8CYZkg2QDzgvSTPDx3lhNdayP952VC9gxzH33mODf3q6tQL2 1Gfw== X-Gm-Message-State: AOJu0YyDwJbrHgEBcUEvUfIPtEy6RIbD7TNBAfz8AiiHJahynMUwGVYH hPk8lwa/2lHRGoejvBNJOv2RX3c9ewPHHGDJtg739AcuTqJhdqstCYOy5kaFyXyBmvkuPYCRGKP gGllZpBGew3Is X-Gm-Gg: ASbGncuo4q4coDUowS/2oD4m/lcA6YODK9s8N98G3+QbiuY3Aj2Yy/sDRV4JR4SHKgM II4Q/eDLHYzqhdjzDtPJm+dfVPnpeW3O+YBX5NniT5yRvHfovstidJWGyCptapJaOnqp6WPgNfg Rs1ulhX2CtPplU+z5STK4WTnB6BC1hyeRE7BND9zwfuiI/LzhqZJ5rG2iN408noCNB+5jj+mDKp AL8DvQdoo99gEXa+pLux8zJWoTxhgR1YrVaJ9cteEEst9DsvB4ehvaSLcT8Rsw7iDSVtqF//Uok FzluQHPPzXjDQiqkQlesRysfvH9MQ0r6HkWbY/b40UfMVjUCJiFMKfDxhlLL/b+iarlLHgLJxNv oZrzOt5WG2VVc9Mx4qbyEEASRoh1ALHqj3GGG2Gbm1HrryTkvnwZ1SgNb2ZKpaqUgMpp8nq+ltT vj/PbCziZiAeOAqaR+LFhT8MJlu4JT2v1a16s+olqMJT/rmg9WyMi46o79DoIHzTetn0gdow== X-Google-Smtp-Source: AGHT+IGRzIrhYQgnZNa1UsjJasERFS3g5yhWVoTj0s36vUq0vHO7BoWVWAI+8mAzPdhsjDz+Utb7Ew== X-Received: by 2002:a05:600c:420c:b0:477:115b:878d with SMTP id 5b1f17b1804b1-477262baebfmr87459415e9.15.1762165006253; Mon, 03 Nov 2025 02:16:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 14/23] accel/hvf: Have PSCI CPU_SUSPEND halt the vCPU Date: Mon, 3 Nov 2025 11:10:23 +0100 Message-ID: <20251103101034.59039-15-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165183533154100 Return EXCP_HLT to the main loop. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/hvf/hvf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 51fd8c7175b..59a2ef53629 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -301,8 +301,6 @@ void hvf_arm_init_debug(void) #define TMR_CTL_IMASK (1 << 1) #define TMR_CTL_ISTATUS (1 << 2) =20 -static int hvf_wfi(CPUState *cpu); - static uint32_t chosen_ipa_bit_size; =20 typedef struct HVFVTimer { @@ -1008,7 +1006,7 @@ static void hvf_psci_cpu_off(ARMCPU *arm_cpu) * Returns 0 on success * -1 when the PSCI call is unknown, */ -static bool hvf_handle_psci_call(CPUState *cpu) +static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret) { ARMCPU *arm_cpu =3D ARM_CPU(cpu); CPUARMState *env =3D &arm_cpu->env; @@ -1091,9 +1089,8 @@ static bool hvf_handle_psci_call(CPUState *cpu) ret =3D QEMU_PSCI_RET_INVALID_PARAMS; break; } - /* Powerdown is not supported, we always go into WFI */ env->xregs[0] =3D 0; - hvf_wfi(cpu); + *excp_ret =3D EXCP_HLT; break; case QEMU_PSCI_0_1_FN_MIGRATE: case QEMU_PSCI_0_2_FN_MIGRATE: @@ -1910,7 +1907,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcp= u_exit_exception_t *excp) cpu_synchronize_state(cpu); if (arm_is_psci_call(arm_cpu, EXCP_HVC)) { /* Do NOT advance $pc for HVC */ - if (!hvf_handle_psci_call(cpu)) { + if (!hvf_handle_psci_call(cpu, &ret)) { trace_hvf_unknown_hvc(env->pc, env->xregs[0]); /* SMCCC 1.3 section 5.2 says every unknown SMCCC call ret= urns -1 */ env->xregs[0] =3D -1; @@ -1926,7 +1923,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcp= u_exit_exception_t *excp) /* Secure Monitor Call exception, we need to advance $pc */ advance_pc =3D true; =20 - if (!hvf_handle_psci_call(cpu)) { + if (!hvf_handle_psci_call(cpu, &ret)) { trace_hvf_unknown_smc(env->xregs[0]); /* SMCCC 1.3 section 5.2 says every unknown SMCCC call ret= urns -1 */ env->xregs[0] =3D -1; --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165149; cv=none; d=zohomail.com; s=zohoarc; b=XLJE29vFF2OMTrMrrqo2CUWWzvi5dl2GY4J5LaSbsQAqYfw7LfTq8GuQobkhwQqqATgQ2outwZRBzY3qzwePtvmayDb3D3GgeHM9liaPTMOtXFHYd46SH7IH+sq4s+LMG2oE+aXyOuFUU+dvynwcTzzZu0lZ/F+rAFYJeGtdeT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165149; 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=xopSbsh+IkB5STrBQ4YQZEElngQLIdle4gTE7izg1DA=; b=KFbRF5cmwGwqadf47bFfh2RBZTSpHiWMeHCLIx9EWgkw8OFE9Q6trgQZJGLIJh9unnJBxs+74bSYYkP8kC0HYer4gGa42U2hMvjNIHFhRNFK3Zv5T6nS+ZQoIaT1uAlr7SSmLfQO5S17Rx/txb93fn7zUfgGNUWAQIr5dahn0T0= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165149613405.91244245112034; Mon, 3 Nov 2025 02:19:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrdc-0002XU-3d; Mon, 03 Nov 2025 05:18:13 -0500 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 1vFrcs-000251-06 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:17:28 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrcj-0003cE-PS for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:17:20 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-475dae5d473so33371605e9.2 for ; Mon, 03 Nov 2025 02:17:14 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c374f84sm145657885e9.0.2025.11.03.02.17.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165031; x=1762769831; 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=xopSbsh+IkB5STrBQ4YQZEElngQLIdle4gTE7izg1DA=; b=kSJPsZmWQj56SC2/2VLpCEhtR8n91eqPIFQMdhq3B+gC3Ac3HahjeRpB9TG7a+OJA+ Lt5T783lthKH966TIdruf74hJ7FwEsEUIZ67mYpbiIKbRVM/tHckObzEcd7WfBBHtd1m zjx/R0zGqHW7NLMzyYm1m0q8lIq8xz1m2vcVoEWOV64jxJ28loHuif6lrK4ansBPGIEB kGcFD0x3DStjYPHun3KYRQUb7/j7CHyTXSIbp2QcwPZBhnw8B5jEfMwl839bDLKYoaCv BEu634evxp8RyIMv7Q9vD4rMCSZdFPPhatpZ3Smy9Llk887NLlasEI5pgfEpq9UHucsb 2JMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165031; x=1762769831; 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=xopSbsh+IkB5STrBQ4YQZEElngQLIdle4gTE7izg1DA=; b=QE4NS+s3FMfyh5cxDSIIWqPtJ6j6p47pKaB2aAVUKert4xzFqtklIUY57Ip33RgLFp FMlfWz6iBBQ408VnwCCP8UMSH6XXbAaqN75QVg5HNc0av3BrWFDY5hAYZcOfeh89J62c SqoJ9d47l2rl9+rnYY3kAkDb4VzvaeJLUU9K38trNxglojNeIgwXDt4XI7HYwm+VuCeN dJ3/LRAYyRCGJaleI2R9V5ELZwKzTU6YTZTayV0aTG89JYvHvFfDKo/HyBZWSC0U1MyX G6RK1LzmHANYnMN5eW7hJ3U+80lGJl6RZZYNNJwCBfbKlhk3oFEpmtDrJS9bXK/yHXsd AkMw== X-Gm-Message-State: AOJu0Yxg66QnmFDuDIK7Q0ho0DMPlGLXHB09MmJ99El7XVMQ+5Ie3tc5 KvTE5o7OdQfmTNGo/nknbFCRFZp4T1y9shGkeLrmMnUmmeFuRzshTEBX9ydmPanAIPiTqIBttj+ jKOeE20FfSj0R X-Gm-Gg: ASbGnctZET9KDI7o6gfz4knHnmyW73SpRWTZWbSPvkPZTvocaUE3PAvnBgsuxdAw7y4 SfPoamy5zK7ajKrCRgE1fI/6L8fhZnGvY8shcYy2V8j/7Hz/TV1PsC9PuHtPbR2UVFDykXBETul n0GI1bkoEbapWphQdFucExkxeDrvy26UP7+QVEB4YGdXb6g57G5+3nZOOMU3q8LuJH1eXec5q+g g9kd5IhnzU45xd86PWTW2lAlBv0lXhQcEKkfkv0SACp5FaeZyZINBKTevWOs3ptnfqERfMjEw5J Y2nnZ8yswMx5ni43cILstcWBZj192HIw09RCf7JOuKJfLNMQhbVkZ2NBUMLsBL72vkWOuWEq2eQ VG52T9sV0pmpyjB85plEU0L9DKuetLVT+nAjmbBzF33Eq49xY9woUQBtiHVK70G5TAE8WDZ/IRM vMSvw+5OcDHNSTk0qqNMR3prFA777Ll/+EtGFERWaeRGLGj5nub0H4AVeIk1M= X-Google-Smtp-Source: AGHT+IHOAD4JCwIUvnVbMcEs4wnyd0qRniJ9uU4UOqtOI+jZFGq5+Vv1/tFufD9GINwceC9VyETFLg== X-Received: by 2002:a05:600c:5197:b0:475:d8c8:6894 with SMTP id 5b1f17b1804b1-477307e4264mr110071845e9.9.1762165031625; Mon, 03 Nov 2025 02:17:11 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 15/23] accel: Introduce AccelOpsClass::cpu_target_realize() hook Date: Mon, 3 Nov 2025 11:10:24 +0100 Message-ID: <20251103101034.59039-16-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165153158158500 Allow accelerators to set vCPU properties before its realization. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/accel/accel-cpu-ops.h | 1 + accel/accel-common.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/accel/accel-cpu-ops.h b/include/accel/accel-cpu-ops.h index 0674764914f..9c07a903ea0 100644 --- a/include/accel/accel-cpu-ops.h +++ b/include/accel/accel-cpu-ops.h @@ -34,6 +34,7 @@ struct AccelOpsClass { /* initialization function called when accel is chosen */ void (*ops_init)(AccelClass *ac); =20 + bool (*cpu_target_realize)(CPUState *cpu, Error **errp); bool (*cpus_are_resettable)(void); void (*cpu_reset_hold)(CPUState *cpu); =20 diff --git a/accel/accel-common.c b/accel/accel-common.c index 850c5ab4b8e..eecb2a292af 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -106,6 +106,11 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **e= rrp) if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) { return false; } + if (acc->ops + && acc->ops->cpu_target_realize + && !acc->ops->cpu_target_realize(cpu, errp)) { + return false; + } =20 return true; } --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165138; cv=none; d=zohomail.com; s=zohoarc; b=leMRqZCXvtauV6vgvlL9ikr6YiGKcQTfxLtvORyUqqw/dYFp6yz7m7QoUMe84YhnNhwdS7hvGd69xUSHs+uoLrzVh4SNc/7MRx/5i+1eQBj4VsQGATn0o4pqg2TUWptJYJOlH9UhtgyvdJTu5wVxuMWcbzEdqWSivIf1oF+k0nI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165138; 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=I/Gn6pj9/95Lzbm+SIWtnMyaV4WJR3oCGo7MQI4hS50=; b=BSJxdDCGsv9ba7qbhiQIaqi7/KE2HFS9JOkTAAYS3DhcfTN4AYmRDK0lLsIQzPShPa8S7hRMqL1HCWKq5xwi8ua+2dIqoMnlWBHf3iVS9ckdr+P7d5l49xr8iHl00e4FjpSWChNJHA/IOEueSASx7bnxwKps7ISPcdh0cuKYoiE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165138594125.69043914556437; Mon, 3 Nov 2025 02:18:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrdd-0002Y9-Ij; Mon, 03 Nov 2025 05:18:15 -0500 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 1vFrdP-0002Nv-Bw for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:18:02 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrd8-0003gV-EN for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:17:56 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-475db4ad7e4so14954315e9.3 for ; Mon, 03 Nov 2025 02:17:39 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c383b45sm148535425e9.9.2025.11.03.02.17.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:17:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165057; x=1762769857; 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=I/Gn6pj9/95Lzbm+SIWtnMyaV4WJR3oCGo7MQI4hS50=; b=XJnnEzck6eMss9mezEbv3edbPX5v3f72Iwh7ATUDQAJDV/LTbi9n1KF3QUYNtSQtA1 M1ePtgJE46hCReXbGcLcHuLQ1kTE2NimHKRoas+gJmj79diYTt/DWMHzSgfmu+54pwsp rnYSdxAFkkHwAeiL4Ieusd3W7Aq1t1dbQ9gq4p7NP+O8hq1ioOEb50tPHpqNosf+xXrN s7XEML6yWagNVRcjfNHCqADrbV+2yOHG8L17kVtAVLYaSUBlJWhiHGHHwrhEZ0HO37BN bxh39sDBqeLUU/wWvXmcGmSYHfAzM+TwXlYsto4SjRD8UcDHx7731qN2FeUt7JLdiGYY 1hpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165057; x=1762769857; 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=I/Gn6pj9/95Lzbm+SIWtnMyaV4WJR3oCGo7MQI4hS50=; b=YHc0uwvoVLNXfwbjYY7fL3yAL0qKesDRj9dOAWxzxpzo5vq2ocAnYqROkOmlVJqGfQ EIIpaqNnBjZhkD4EMAuyVLWiuvvui/GiLFGgb5qc/Q6VU2swg2CsNdcLP19PeQ9TpeUR KmH8Y+Et0qj6DxuZoQUUHjttWKLlrbZdIf6X7wLI1ayuNmTq5Y85g2mK3HtacXTRYSIO jHcXCozZ78KU0khphl100k69oKc2HimWBnAQuJOl+W3e0FjGXjhhEbDi1FCFhZTXCQle 1pJDvpQHRiTGblhDK78JHQZJpdvnm8k++OeEe5TAMUtn40u3l7ckCOL5t9ipNDxHI92M TUdw== X-Gm-Message-State: AOJu0Yy0BlSASHtizaTER5zv5s1PaiBGFXYNn85e/OTThZFqVjrFR1wi qclXuNI8kYZgaj7INmDRwZt08mkoTR0hiYXDJo96EvqKQognYeDGJxJwcpPmTSoq7oPmGJMkBZ2 wM7J91K1p9uhl X-Gm-Gg: ASbGncvEU3av2nCfN+fs/K0v6GhWD+E0+A/7erdthUSJ8fVhTm9mBTMT2o9zbkf6mua b1glLpk90PojFJ4tzpipMgxzmTpr6tgSp2TSnu4PNXeZxc+OHcan9iKWWcxAXqh7OinlSPkFuNw Fr09mmmV0QDasad3ypzOEeW6O9VIXUFYosykerfZ8aXwU0AtCWy46IY6w3LUhknuL970Gna8nN3 BEoglkDiAtWSK52njMvhpZGCzvR7MmUaBK6VhiQ8szUSPDhDLqGGeD4ehEL7DJUDBmt+kCYifnF OWwgDjas9vYXotxrKDbymRPCeOnn/5y2vbwEzbapTFlmePwvQx4iFVywtiQEvV3qKZcrrzxzicu J0oQ/HLdnYylfyZnuMghTRz15Rulal4c+jzWeYxx/OK0WlOUF7XhKrQKj6PWQqQf7o6vPcNA04A kuQl8dtgYO3Anu8un69aGQR3EWqi6ImCFei/5HTZRADGCBki4jTOb4N2s7kA70+B4nMc0xTQ== X-Google-Smtp-Source: AGHT+IGGchD+wIOw2aXOqsLwke9vqYQ4Lq3oeeRPMPF/DZTBQlrrQs8n9AoCfzHlckli0oZf++JqFg== X-Received: by 2002:a05:600c:1c1d:b0:46e:39e1:fc27 with SMTP id 5b1f17b1804b1-477307d740cmr104585555e9.5.1762165056739; Mon, 03 Nov 2025 02:17:36 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 16/23] accel/hvf: Add hvf_arch_cpu_realize() stubs Date: Mon, 3 Nov 2025 11:10:25 +0100 Message-ID: <20251103101034.59039-17-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165141389154100 Implement HVF AccelOpsClass::cpu_target_realize() hook as empty stubs. Target implementations will come separately. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- include/system/hvf_int.h | 2 ++ accel/hvf/hvf-accel-ops.c | 2 ++ target/arm/hvf/hvf.c | 5 +++++ target/i386/hvf/hvf.c | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index c8e407a1463..96790b49386 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -106,4 +106,6 @@ int hvf_update_guest_debug(CPUState *cpu); */ bool hvf_arch_supports_guest_debug(void); =20 +bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp); + #endif diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 5922eb02e70..02c5d01670d 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -356,6 +356,8 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, c= onst void *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); =20 + ops->cpu_target_realize =3D hvf_arch_cpu_realize; + ops->create_vcpu_thread =3D hvf_start_vcpu_thread; ops->kick_vcpu_thread =3D hvf_kick_vcpu_thread; ops->handle_interrupt =3D generic_handle_interrupt; diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 59a2ef53629..8208d345daa 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -972,6 +972,11 @@ int hvf_arch_init_vcpu(CPUState *cpu) return 0; } =20 +bool hvf_arch_cpu_realize(CPUState *cs, Error **errp) +{ + return true; +} + void hvf_kick_vcpu_thread(CPUState *cpu) { hv_return_t ret; diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index d0ee00425f0..1b189efb4c7 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -370,6 +370,11 @@ int hvf_arch_init_vcpu(CPUState *cpu) return 0; } =20 +bool hvf_arch_cpu_realize(CPUState *cs, Error **errp) +{ + return true; +} + static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idt= vec_info) { X86CPU *x86_cpu =3D X86_CPU(cpu); --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165186; cv=none; d=zohomail.com; s=zohoarc; b=MUP9SFTRBQaDBbyDlbe6LCQxvVeoJlIUkiNmHon0qiCLKPq5Rw603yJB3L6eXwayyZgswaPYHqyCwoFMGy/5bG6Z+A71M2uQjAoMLFH2EfwdGUlkRJOQscduNBqa1C/7DiDylzJDqbj8R2b8Ts0b7KyCTgfo2+bw4JtaV70MbqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165186; 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=R3F2C6kHHPWBiLc/P72P8z+qmvtuhzoJzLzlQGryUqk=; b=fEtz6Uj9uEbtIsfSz3P/GDT8YCPCbXouuza7kNG41TWsAzxM1bon5qiaw97TRnJNJlV492nYUeexluiKrZOiDB3i+ImIhQqS5kD6kcPZhuIvyl8fIU0V2CJa7W9w6Ut0YZV3TbwK4/00/8/pI2NwhoZ/kq0fjZFBu55uXC3eRzc= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165185996446.6838768849377; Mon, 3 Nov 2025 02:19:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFreE-0003Ud-Nj; Mon, 03 Nov 2025 05:18:50 -0500 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 1vFrdg-0002gr-1D for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:18:17 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrdc-0003iP-UR for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:18:15 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-47721743fd0so22230275e9.2 for ; Mon, 03 Nov 2025 02:18:10 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c9737830sm13128551f8f.16.2025.11.03.02.18.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165088; x=1762769888; 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=R3F2C6kHHPWBiLc/P72P8z+qmvtuhzoJzLzlQGryUqk=; b=JrXWm2i9sbKlmU/fHc334+I5nClMLqz9Bg41QWiBktGFaiI0UXO0GiUkC60J7mJkZf 9xFV892SKWeBelg2hSVHGQ4gyvvqxnP3PRN76//2qFzvj94jzYZ6mf0LKqwqUsY3ynAa ysX4v1svlNIJakK5M3Lt2UKAKc91+UElxsJeneDvi6A3G8pB6MlptNnc5AVzfWaUHkgx jVAN64gfi94Opf6SEoPkzWHRXVorM6zddlc6Cl9rGhQW2GO+r4Eq6/iSFkAxUnTOhPka 0VEHWmbN4st43GC85UzH4XhKcEU112MtlZ/82rWs6nJydqfUFJLqoJvwz8pfQfxQIjq5 mvNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165088; x=1762769888; 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=R3F2C6kHHPWBiLc/P72P8z+qmvtuhzoJzLzlQGryUqk=; b=cxI2HfEBeuBIszACqYxA0QotbEpUPubnFAi1NzsYe8CNjTW4/DWaYkEG1ekttTI0/M jAYDgJDSF/DJt6SMVynoIPlZ6fCUOCq3T1F7bGKmKlbuBaJvpsBqviSyLP4G5lgHeqLv Y0ThQMWdM82Wo60FDclLLOxL4RF0IRHNS01ahnlIdezuV9LOiaA6E6GDvgpn5FC035yC WsmrgidLs3cgroLjDnqG2KZOM+wAR/BfWTiGsGlLMRmS2oKJRjun9LWWeRdsfOj9hVSe eeg+TtdRoeMOk+k52n1bXqg1xAqx41Eq6mWGi6/QioF7B29Nc8WN51ZXhVAsUi5WMSTf ebOg== X-Gm-Message-State: AOJu0YyhQAiL8zuHI8BgQhyLvpuujAdiZ22VYLqs+Z3QPS5owi7sYE5+ 4TxwzWRPJXcxsdxa93Q6GauHY5rgk3q4s2jEa++SDOGEXsi8XdJ4NoZwVd6UiNtPwYyh0zcGBks lie+nMOeC5tbb X-Gm-Gg: ASbGncvu6dakyd6k4N/c1b2etQrFc52xxuPigWTQR3Pm4onHq6bRcNJxlMktC9TDsUp Aj6RQ7D4mCtd5K2Cn+Lm14MOSpUJPB5HfN7YgDgeq8eNdOQOdR6L8ZWqlwDvOIX/PVZc33hHvZJ qG7fTNdVoIin7Am1ATPMVlDv8FwPo9nQ7AzVrJSzSkPQ0DcLcBi+F8/iYox0AyMX3cMCPsK3XgG +cHmOji+XLB+BMJLiYB7hOWb3p7zm5dFdmyJOj09ze+qM+KQb/NySOLvcAdLEzSirLLvSGWKWdD xjJ3JmkjUnriP9gJMGoxuTJ140pRKfD61I8nmWki3NBWlNMucXlkAkRTxcfroQs865BWTHFuegV H7EBI8BvKxatqh42P3NEQVa8vjtJsFG+bCE//1f8fwqOauV/sEY0sz8CzsPddYnUKyEE5PcuBfB LHCFxHLGO3VCUfF2qk8QsDgzHySFFDoX4etR/iyexdVTTmgx880QGizQg/rkoniV9y9w3meg== X-Google-Smtp-Source: AGHT+IEHuBq/wFHmCFTx2774ySWL/Ys5ewUJW7M2q5VLL+eU7EDIg5S4F5865RPivRb2YxgNsYDZ9w== X-Received: by 2002:a05:600c:1f8b:b0:477:a9e:859a with SMTP id 5b1f17b1804b1-477308a06e8mr99471905e9.22.1762165088224; Mon, 03 Nov 2025 02:18:08 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 17/23] target/arm: Create GTimers *after* features finalized / accel realized Date: Mon, 3 Nov 2025 11:10:26 +0100 Message-ID: <20251103101034.59039-18-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165189480158500 Call generic (including accelerator) cpu_realize() handlers *before* setting @gt_cntfrq_hz default Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu.c | 65 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 39292fb9bc1..b392374df98 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1636,26 +1636,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 - if (!cpu->gt_cntfrq_hz) { - /* - * 0 means "the board didn't set a value, use the default". (We al= so - * get here for the CONFIG_USER_ONLY case.) - * ARMv8.6 and later CPUs architecturally must use a 1GHz timer; b= efore - * that it was an IMPDEF choice, and QEMU initially picked 62.5MHz, - * which gives a 16ns tick period. - * - * We will use the back-compat value: - * - for QEMU CPU types added before we standardized on 1GHz - * - for versioned machine types with a version of 9.0 or earlier - */ - if (arm_feature(env, ARM_FEATURE_BACKCOMPAT_CNTFRQ) || - cpu->backcompat_cntfrq) { - cpu->gt_cntfrq_hz =3D GTIMER_BACKCOMPAT_HZ; - } else { - cpu->gt_cntfrq_hz =3D GTIMER_DEFAULT_HZ; - } - } - #ifndef CONFIG_USER_ONLY /* The NVIC and M-profile CPU are two halves of a single piece of * hardware; trying to use one without the other is a command line @@ -1702,7 +1682,40 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } } +#endif =20 + cpu_exec_realizefn(cs, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; + } + + arm_cpu_finalize_features(cpu, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; + } + + if (!cpu->gt_cntfrq_hz) { + /* + * 0 means "the board didn't set a value, use the default". (We al= so + * get here for the CONFIG_USER_ONLY case.) + * ARMv8.6 and later CPUs architecturally must use a 1GHz timer; b= efore + * that it was an IMPDEF choice, and QEMU initially picked 62.5MHz, + * which gives a 16ns tick period. + * + * We will use the back-compat value: + * - for QEMU CPU types added before we standardized on 1GHz + * - for versioned machine types with a version of 9.0 or earlier + */ + if (arm_feature(env, ARM_FEATURE_BACKCOMPAT_CNTFRQ) || + cpu->backcompat_cntfrq) { + cpu->gt_cntfrq_hz =3D GTIMER_BACKCOMPAT_HZ; + } else { + cpu->gt_cntfrq_hz =3D GTIMER_DEFAULT_HZ; + } + } +#ifndef CONFIG_USER_ONLY { uint64_t scale =3D gt_cntfrq_period_ns(cpu); =20 @@ -1723,18 +1736,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) } #endif =20 - cpu_exec_realizefn(cs, &local_err); - if (local_err !=3D NULL) { - error_propagate(errp, local_err); - return; - } - - arm_cpu_finalize_features(cpu, &local_err); - if (local_err !=3D NULL) { - error_propagate(errp, local_err); - return; - } - #ifdef CONFIG_USER_ONLY /* * User mode relies on IC IVAU instructions to catch modification of --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165185; cv=none; d=zohomail.com; s=zohoarc; b=UkNOl8DChpAD8d80OYx6Uuxweqnw+OIyIUAuvTa9YgVp5zV4+f74l9eGeNw+74EcKKnO08GP1rTTd8ggDNX8R7e07lVMb6zGxm4AacBtH3HzudmyLvIWGSEvYUdQEvDbBWQSDPYXwMYUP5aT+VXD+/0Mh2muqqJxdBcFEq/1U70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165185; 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=UvXFIS/LP/8nn2LaWPgW13nQ8RvlKKCfqWkyp2+R/Cs=; b=Og1T9wfciFao3VuTsuGhp/DW6jlijCrHH5hF+nQPf4POSzMwlN2CnsQtL/7jB/eNdcDpqd42gWIrq4laRuMQO6abUmcXDnNcaMJgbh49iGjvimY4t8XcvLHbVF60J0lMqflE4MTFSW7yVimeIuhY44vPbeh7MlQmqaMinTNWtGE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165185559185.84462312403764; Mon, 3 Nov 2025 02:19:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFreQ-0003nE-KH; Mon, 03 Nov 2025 05:19:02 -0500 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 1vFre2-0002tn-Kw for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:18:39 -0500 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 1vFrdz-0003lo-Oc for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:18:38 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3ee64bc6b90so3382842f8f.0 for ; Mon, 03 Nov 2025 02:18:34 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4772fd280fbsm85650255e9.5.2025.11.03.02.18.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165112; x=1762769912; 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=UvXFIS/LP/8nn2LaWPgW13nQ8RvlKKCfqWkyp2+R/Cs=; b=ADyeT/MkdtsAQqHfgtIP7XX2MU+pNlm/O2hULik6qXByTAdxOPWzcymzROH6il3xd7 BXU5pWH26nDQfQbrfQC4mCSrTrcOakSD2atuXCKBjRb/2SU2Y2wodwYhv/QaKc4iE58m fax1ij519ckI9Ux2yWORG05NJea9qPZc4IR4BTKxxQJa8Y1G4C+4E1Vn+HoSqhJMrPNM bWBVaRnyHPedS08fE2WBMWlLQ8tmYCzhSXsLtqXUaVNEWpkxl1f0xMPuRDI6FOdb+Bm/ BgqwT++dviNQyc3I44DlLtqxLp750EFLy1Rk+oc5BZ7XZIA3BJWSj1ISWFVK9YTMOy3G d4cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165112; x=1762769912; 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=UvXFIS/LP/8nn2LaWPgW13nQ8RvlKKCfqWkyp2+R/Cs=; b=xTCp7kKt4EsHqrsLMsWE5aF59y1G7SivKpAFTLm4Mjnml74PLNI7OvVWzzpd5O3mV8 PXj/OzXRwaainFnkTQmUc2UDu3N6rnttKG88QNRdUzI+5FNaNItQKShJzaOmEXcIhh3J zFufjVYfw+mDbYb2TEJhwQrAvz0wyCDiqQQvetkqb/HYl6JNpZTrByxT4vePFobIAAHK s3HT2taQQbSQ2woiEeKOpZLqAHpM74jwW7LxMLV+sx/oOYiEXsTMOdBDeSKre0WNAwPu hk+BriS448XOkPnNmxDnK+Ipc++RHJpEoGqolDsA2LoWY/lDYF334L/IQ6oPqX9s7sJh hCpw== X-Gm-Message-State: AOJu0Yw85Ub6P27Wiajw+pBa0nMqzcqKjzT2sKMRcAYBq2Ci7xa8xG3O pehJ2d6jT6jIAfu0f9W/Qa/xjwgktAQsYQyiSl9o97M3Cb8PybADlmbpLzoFtq3lBZNzZ4wS88h Dc3Mk9L7Bqdf2 X-Gm-Gg: ASbGncsElNEOj0R1ZN7A/sBkyqiAiXKoszeZ5xwkqnC9Nvs/vpuMLQFXF3S09NnKIfY HaM07eSiHpyS2TzQFSS0ubGQO2MzwagDcTG2q/stNdzN3JLPMX0PnF928caXYc+p2KOfUCB1jSz 9bwSQZmh0ydclct2/yzH+Lwaelqdf7cwa81rcqerzCOHZa4WcJFsCyZT1wO/3BYGi94OzqlOn1i 6bdJn8a2R+oLqXbWe8eDuw7xkVgQgYovdBREyWAoa3ho0Q5UF9vwxBxeZ7Ws7oQhMkx5q/JfHM/ XxSv6ulpBffUV9YWt4V6jMEzATHri2/mRXXI3xmBU4u2n6iwCN6/ya/IwbCLihA7N1lELfs9vYZ uRDtSOWf3Xi83i8jXyVxqyNMlIJbKdYlKXZyfsy3PBKRopElr0OI6T/kDa+4DRu2aNYJeC/kxPU N6a58Pced2I0GeVJZFsGNpjwr3CFOHL6zQL4bqeCGz8PyXxILFRxX8jP0LB47q6tYLnI23cA== X-Google-Smtp-Source: AGHT+IEZPmXb9AuZbO3edqPAeyC3GTTTsz0OrkAmCVLQWI7tHPkC2qbXn4ILunz1PRBvcZ1LcLlnbg== X-Received: by 2002:a05:6000:2f86:b0:428:1475:6a26 with SMTP id ffacd0b85a97d-429bd6b354amr10603949f8f.56.1762165112453; Mon, 03 Nov 2025 02:18:32 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 18/23] target/arm/hvf: Really set Generic Timer counter frequency Date: Mon, 3 Nov 2025 11:10:27 +0100 Message-ID: <20251103101034.59039-19-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: 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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165187571154100 Setting ARMCPU::gt_cntfrq_hz in hvf_arch_init_vcpu() is not correct because the timers have already be initialized with the default frequency. Set it earlier in the AccelOpsClass::cpu_target_realize() handler instead, and assert the value is correct when reaching hvf_arch_init_vcpu(). Fixes: a1477da3dde ("hvf: Add Apple Silicon support") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/hvf/hvf.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 8208d345daa..e1113e3d6ca 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -897,6 +897,13 @@ cleanup: return ret; } =20 +static uint64_t get_cntfrq_el0(void) +{ + uint64_t freq_hz =3D 0; + asm volatile("mrs %0, cntfrq_el0" : "=3Dr"(freq_hz)); + return freq_hz; +} + int hvf_arch_init_vcpu(CPUState *cpu) { ARMCPU *arm_cpu =3D ARM_CPU(cpu); @@ -908,7 +915,9 @@ int hvf_arch_init_vcpu(CPUState *cpu) int i; =20 env->aarch64 =3D true; - asm volatile("mrs %0, cntfrq_el0" : "=3Dr"(arm_cpu->gt_cntfrq_hz)); + + /* system count frequency sanity check */ + assert(arm_cpu->gt_cntfrq_hz =3D=3D get_cntfrq_el0()); =20 /* Allocate enough space for our sysreg sync */ arm_cpu->cpreg_indexes =3D g_renew(uint64_t, arm_cpu->cpreg_indexes, @@ -974,6 +983,15 @@ int hvf_arch_init_vcpu(CPUState *cpu) =20 bool hvf_arch_cpu_realize(CPUState *cs, Error **errp) { + ARMCPU *cpu =3D ARM_CPU(cs); + + /* + * We must set the counter frequency HVF will be using + * early, before arm_cpu_realizefn initializes the timers + * with it. + */ + cpu->gt_cntfrq_hz =3D get_cntfrq_el0(); + return true; } =20 --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165203; cv=none; d=zohomail.com; s=zohoarc; b=WSI+RwyzqHPSPXdXzma9PLCyNCBeBpWl+3ANSMLoGxeq2PG9YVhJ5PIIVZiReXvcgGq1R+3IahXHre6ZxuFK98DHizNn0BUtUTJaim1d4I04xnsVKsKpU9BuaoDkPSDNNCmEd+LorqI0zDXNVSV9PRLUMRW/XKK8MIiFbIZsK/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165203; 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=EMDbgyBSsHgV3ZURAPo979wxtIvTEY+Ozps1vZGgi5k=; b=lwS4FPfCi74tl7r1c3wyflPSXQMsNmE29cTcxY6G0VVSgJ1i37l/vZIEGcNWM6oNmmiEQuHJ2CeME6UVCMkp66N72OiZtb2IVLEm2XFFJPgSRu7QVZz8bP2RaQpuxZ1ypkldeeZS7CoTR9qb1NNDzFiv/2MEB98KAjpGOlEl7mg= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165203530430.05442626883394; Mon, 3 Nov 2025 02:20:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFres-0004nX-Qg; Mon, 03 Nov 2025 05:19:31 -0500 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 1vFren-0004f9-N1 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:19:27 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrea-0003qx-Eo for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:19:25 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3ece1102998so2740162f8f.2 for ; Mon, 03 Nov 2025 02:19:08 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c416a0e5sm18885013f8f.15.2025.11.03.02.18.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:19:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165141; x=1762769941; 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=EMDbgyBSsHgV3ZURAPo979wxtIvTEY+Ozps1vZGgi5k=; b=H0/Px8frem0o4y6a6g1rr6jkWB1TSSotFn3s7HP4NEUpEZINy9mMtdWkCzxKvH5AjU 7N2Vj+H2/uNbD1OyNw4z1JyB2LS8pHYSaGw2WVPCbhT7kNnprjU3RnhC5esdzui6qZpk R5D/d8m8MW8+124xg5QbCWOKk+Tb093Xu+Ao4O28Z/YF04ooQzvkfQJnvKTXShAoXF/E ha1i07pam377H3y/8HbKIEQYtyY0Ed9HTNYpnhkZVWdgB7tyuKmRNfl4FWJ4dnv6HsOs F28+rDHJRLiEbVI6rANmW9VWNED8fYbETJRb5KlfNsQuAv72QhV5krrTcioPEqbKL6Pm /mjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165141; x=1762769941; 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=EMDbgyBSsHgV3ZURAPo979wxtIvTEY+Ozps1vZGgi5k=; b=s77nQwsUZK8MhJnjvyBwmtGLsmrD6TALvPLDv7KmlkU6tUgzANAWlyXWiWJV45zBL0 DJCSh4J02e4mdbFOAntcR70nYkwLAvaM9AVq1MhEBUoI08iFDTSgl4vcbiMrrM30H75V Vs9kdJk35wyVmNNGlUoL58EKre0wFyKISdi5Gv9nrdZWokuURMYhc1T7mLq2O29S7al1 cjIO3Mgzx/EjC4UsxpNf7QuCgo7+ey8z6RLYa2VlxITkF9ZEALkgSHBfUpRwSZwJTqt1 v9gfKgczHy4LvxhguoLbvFoiRdCanj6mb5O7F1pjeFKhy8CWRx53fX76Bkps/T7paVwT 6cjw== X-Gm-Message-State: AOJu0YwoKbxQvMjgON/d7yLe0Ci2d6TV0p1p1685Gj9iVfw3yZyLT1lT bd9WjRnw28avLbxEAbRNUZ8EsWCbEhW6qzO+/RVvLlPBYp535tRQuO9F6hASJF5mGpGTDhBrKUU dOIStpz1jplQA X-Gm-Gg: ASbGncsRi9TA1i8zS1tGxSKTK/d+WPNH3iNp95Sj+7LZOqsQ513jqoLPNFEoBbyzVhA GztLhm4q8WIOILaQ+vpWllaedYEDjruXH2mG7WuVJgbEgQE8aedJmuA+Xb6501qy3M4t+tObqyw KbmPGmzKFkdQ3pr86B3PJHS1/q/DlVP46z8MgOsHo0yEVTIBtu/kcv6XrU/60VUgpnJb4xJd7h2 SCb95Ax86hVTK8QGegrBHJ7D4gf9R0agJN0sdXv0aKzNvDgNUy7lk3rWBTIJsThM1gdul6uDgOm u+NWOKpmvN+/n43iUctYa6N6+E564l/nLRsNm4Trkhv3vhKS/Otorm48AfLCyvYoefrVP8ETkj2 zzszRFi+pFKQeXd0EkmlIFW9DBDwKycDha82S3nKtVMJCG7D93ZN+owCuEEJzrCkDMSc0Q2Vbmm A/kWs1c+0U6IDg0foE5A/zw7VNy3hL0fW1zwwyigMuRyUAw3axJNFd0b/teH/2dAAG/zwbQg== X-Google-Smtp-Source: AGHT+IEew+fkDxf880QsPHk6Gp7xa8f918tG9GQSwtIJ3D3IHUIJU2SAnjV9AL7n+01tFicGY8Zjmw== X-Received: by 2002:a05:6000:2306:b0:427:652:b7ff with SMTP id ffacd0b85a97d-429bd6ade1fmr10263405f8f.60.1762165140879; Mon, 03 Nov 2025 02:19:00 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 19/23] target/arm: Only allow disabling NEON when using TCG Date: Mon, 3 Nov 2025 11:10:28 +0100 Message-ID: <20251103101034.59039-20-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165205730154100 Only allow disabling NEON when using TCG. This avoids confusing user experience: $ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=3Doff,vfp=3Doff,vfp-d32=3Doff qemu-system-aarch64: AArch64 CPUs must have both VFP and Neon or neither $ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=3Doff,vfp=3Doff,vfp-d32=3Doff qemu-system-aarch64: ARM CPUs must have both VFP-D32 and Neon or neither $ qemu-system-aarch64 -M virt -accel hvf \ -cpu host,neon=3Doff,vfp=3Doff,vfp-d32=3Doff qemu-system-aarch64: can't apply global host-arm-cpu.vfp-d32=3Doff: Prope= rty 'host-arm-cpu.vfp-d32' not found Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b392374df98..eaf76532eca 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1460,7 +1460,7 @@ static void arm_cpu_post_init(Object *obj) =20 if (arm_feature(&cpu->env, ARM_FEATURE_NEON)) { cpu->has_neon =3D true; - if (!kvm_enabled()) { + if (tcg_enabled() || qtest_enabled()) { qdev_property_add_static(DEVICE(obj), &arm_cpu_has_neon_proper= ty); } } --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165234; cv=none; d=zohomail.com; s=zohoarc; b=KO2L9C/GEotW8ewNoAixPbb8BSt8b7Ihizxt7eFzlG3hz3ffS6CgPllYOIaJ8hecvPDdp2E1T9B0kEjc6k09Qn5JRAe+e08TNBT5no5y2WNaGdyr6nt7ssaeab/os/QVy7HdGGks98pl7+tXRqBsllXdffa04r4BILbGZ0CIvaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165234; 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=TGSMP/2LGUaTeDayCsmj1/W99MoL27fCEOy6TYG+rnA=; b=g3FsIGzGh/OGR2vtQ5b/VLPbLzWF1OwLJ3SfXCtSqojPx/tpq7vFIETf8SZVi/U5bu3iaSCdRVTNKy1tkh66c9YRTR3ofnMot0LqYcucJDX5vDsPbJGpA6/s/lm38W+n5sZFhbTejeVcEwy+8DhY0mq94pYcJ9/si/tV3+ehiNM= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176216523425185.73969131218576; Mon, 3 Nov 2025 02:20:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrfR-0005df-P2; Mon, 03 Nov 2025 05:20:05 -0500 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 1vFrf3-0005Mw-Qg for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:19:43 -0500 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 1vFret-0003u4-02 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:19:40 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-47117f92e32so34107545e9.1 for ; Mon, 03 Nov 2025 02:19:27 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c394e33sm147163355e9.13.2025.11.03.02.19.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165165; x=1762769965; 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=TGSMP/2LGUaTeDayCsmj1/W99MoL27fCEOy6TYG+rnA=; b=P1WPAIYbcZC/5ZEKAzqlMvT3Kiycpm0QiXrhzULxBlxzkO2gkguLWkUs6y6C1ZnvzR cunUl/pO7VG7rETDnN9GpnqAkJi4Knxx62/ENJgG2PJHLVEu93MlTsK9gtua0s77xCWf 1RRCUiYSZSQfsbcC0AQ/YiONFicXR8e5Nl2kj1ogVvhTQQ4i37ro/ImY0JN8Htx68Ljy I5w+CAHLmDDqtLfJsy/mxfoKP/F/Da1hrIVlZdllcA5s07dWEZcQvt4lIt5jt9WK7s5M cPV9bogKhPtktK73U4Z5DbMBFxFwciScxIBRwfBPM9BQfW0A3xAGfWDWO7Sxuw55d3xQ rD0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165165; x=1762769965; 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=TGSMP/2LGUaTeDayCsmj1/W99MoL27fCEOy6TYG+rnA=; b=rSs7dqmPj16IpcQc7IhFTGmRo6ZLNsgWiu8XlJIno5sUaDOmdMhvrOLZCJvklBXefN 8kJXxray5r9kKpDaB7iTMqMhdjUtzueZCl5liJPvgcoCem3vA1NogTYIT/IfoWxXMqrd lC+Vm6JN/JURvbtgNPXBcLjQTK1re//DnKmmcgAjv92bjgocO7dsrFCDIRGOfPAE5Qya DRyeballPgSBXnO81FNOdM52N7Rnj/Oe/AyGX7OyWkOqpGJ6YhAVX3UPYqLJT3XVW7/O njKsgj89gcxB3s2VJJ3tDphopB8QSOu/A69oXe7wMh22ywbuAY5xMsnhe9NpJXYTPRfF SitQ== X-Gm-Message-State: AOJu0YyiPUWZGNbCFnTmSp99xAXKfbZeXnw+yffxqEdw+pG9Ch8NxJ95 Rb25o0hWgxyb+PuG+ST39jtHgW6OgCPWeHmxFKdBSuZwgrniF0ye/Xr/VOQUH1uGSyxdNfBbMkv 84lCHaEAcwrI1 X-Gm-Gg: ASbGncvFaLr2Tik5LA6J7jmY1cH1jqsjQZNNjiJHZQAjqveMTOi+PjpOtiltd0hVpfA 5KtJNyEYoVbUJxAs02iHNQO1tBL6pysehV8zItSGytQxIb2+WqwrN4GYUhc0F8im8J0EZ8cKetG YjEnhdRyV3PPJkF5A70josnd52pxRLZoEod92hmFQzBvxJNnfsMEDQGjzoqjLjvv6RKeL3MhVG1 iPtUL39jPMmwIdDS2lAoGZlMfURzmmN1i7urEbpVsYQ2rFIxRvwDmQHwjHuLBprLzhHlqgWlRjZ ziu71nLMicWxpK0NhjJubAPCn8zRBe6GR9GGxMQebBI6j9rJgszhsyym8ot54dDoiwUrij/Vss0 nnprnjnPJ6HH07a7mhahAOh2v4neFEidS8kb49qAbiaKE3rluQ+HwiEKiJdh+TNclwZS8kfHENS 5lrmYcs+byYllJYvUZNSqHrghCCPHpCX3X5kM++NkjEyUmK0GCL1wpL3+Xu4c= X-Google-Smtp-Source: AGHT+IEymGYdV8WsItyND7+doV1eIAdKJbS2/7U/v42pDsTyJN6V5G5qWijc9dS6H3OV/Cw2FpG/dw== X-Received: by 2002:a05:600c:4f0b:b0:45d:d353:a491 with SMTP id 5b1f17b1804b1-47730797bbfmr94954045e9.1.1762165165323; Mon, 03 Nov 2025 02:19:25 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 20/23] accel/hvf: Introduce hvf_arch_cpu_synchronize_[pre/post]exec() hooks Date: Mon, 3 Nov 2025 11:10:29 +0100 Message-ID: <20251103101034.59039-21-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165236021154100 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/system/hvf_int.h | 4 ++++ accel/hvf/hvf-accel-ops.c | 2 ++ target/arm/hvf/hvf.c | 8 ++++++++ target/i386/hvf/hvf.c | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h index 96790b49386..3120a4593a4 100644 --- a/include/system/hvf_int.h +++ b/include/system/hvf_int.h @@ -71,6 +71,10 @@ int hvf_arch_put_registers(CPUState *); int hvf_arch_get_registers(CPUState *); /* Must be called by the owning thread */ void hvf_arch_update_guest_debug(CPUState *cpu); +/* Must be called by the owning thread */ +void hvf_arch_cpu_synchronize_pre_exec(CPUState *cpu); +/* Must be called by the owning thread */ +void hvf_arch_cpu_synchronize_post_exec(CPUState *cpu); =20 void hvf_protect_clean_range(hwaddr addr, size_t size); void hvf_unprotect_dirty_range(hwaddr addr, size_t size); diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 02c5d01670d..56ff259a14d 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -177,10 +177,12 @@ static void *hvf_cpu_thread_fn(void *arg) do { qemu_process_cpu_events(cpu); if (cpu_can_run(cpu)) { + hvf_arch_cpu_synchronize_pre_exec(cpu); r =3D hvf_arch_vcpu_exec(cpu); if (r =3D=3D EXCP_DEBUG) { cpu_handle_guest_debug(cpu); } + hvf_arch_cpu_synchronize_post_exec(cpu); } } while (!cpu->unplug || cpu_can_run(cpu)); =20 diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index e1113e3d6ca..8d0a528dceb 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -2017,6 +2017,14 @@ static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_= exit_t *exit) return ret; } =20 +void hvf_arch_cpu_synchronize_pre_exec(CPUState *cpu) +{ +} + +void hvf_arch_cpu_synchronize_post_exec(CPUState *cpu) +{ +} + int hvf_arch_vcpu_exec(CPUState *cpu) { int ret; diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 1b189efb4c7..5134f302c08 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -729,6 +729,14 @@ void hvf_simulate_wrmsr(CPUState *cs) printf("write msr %llx\n", RCX(cs));*/ } =20 +void hvf_arch_cpu_synchronize_pre_exec(CPUState *cpu) +{ +} + +void hvf_arch_cpu_synchronize_post_exec(CPUState *cpu) +{ +} + static int hvf_handle_vmexit(CPUState *cpu) { X86CPU *x86_cpu =3D env_archcpu(cpu_env(cpu)); --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165234; cv=none; d=zohomail.com; s=zohoarc; b=kjeL1xTkACdEzO7tikZi9CiSUZ/yP53xHPnLDp0mkmyaRwp8jXjmSDCra4lpDRDCLTE96EBVdJ4c6S87CzAv+i93aK0dQ/FCcNJAT0KHIEa01S4Wld59szGtOrWGFo/WWtHOCZlkawv0JS9rynB1dxuSnjqMZsZ6Bz6xgIV5XN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165234; 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=+zQ+kr7tsJFbwFHKOahptlya76rrqrFtmiQlsKMFVa0=; b=DqbZMwPJdsTOQRvFbcsGOW7Zbs7Kr6ryaopZ+Er0/7ZDT4VGaiZwzDjBHTOxCm3wYkvEo+H+DB0YBcyKPOss6jpmVwr8WgwtQoAdGG0dM3NWXHCloRVJgsZIKngt/7wv2b/cj/5J/3lp5aLS76dWlifkMozk4dJFo/Pj1yp2muE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165234177424.8040900378827; Mon, 3 Nov 2025 02:20:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrfe-0006bz-Ae; Mon, 03 Nov 2025 05:20:18 -0500 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 1vFrfY-0006Ti-M1 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:20:13 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrfO-000402-C9 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:20:12 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-47710acf715so20381515e9.1 for ; Mon, 03 Nov 2025 02:19:56 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4772fbc32d9sm86170835e9.1.2025.11.03.02.19.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165194; x=1762769994; 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=+zQ+kr7tsJFbwFHKOahptlya76rrqrFtmiQlsKMFVa0=; b=A7+mxddKlKXPw4YSn9omQShB6YxHmA8sPquPdDDPiZk0qiPzfhY56q1cMNLAX4AU0D nMuTmiogdqZPSTC+3L+wpuQh9ssVbYrd84ssqN4pZEL6x3mJ/AiypXPzr3i/LJJogtPx w4rsutNtwd6vde4i4uD66EPitzOAhUGdWVz6RlJIhPucw46eYJDhcDVL3eMXWkDR5THB slHJfTFK4LtE8xNbl/oDvs/s+M24+xPXeXMTmKb0Err3o5se/uqUCWJex8odTHy8TW54 LPv0PENnAcul5eax9n4UIKLFNZpzXZYFgvgZ7GyDiozca7VNOJKwU15XjSss8XJTQ9x9 EOcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165194; x=1762769994; 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=+zQ+kr7tsJFbwFHKOahptlya76rrqrFtmiQlsKMFVa0=; b=fWNbOuDQt0HeIlPGuzWlasAKkHelM8CKE4kWcGiQzUYnzNuY/wcB+aBsgBAW8Bh3Yd 4kvpAdf8C70PuuX8Q0L/rFksQAKHG+hXY/Kbu8YC3vvyozfJaI3vsQtnpXALEjZTXGko zkgxYijUFvZ2UgdzCIl80yHfrk33djfQY7DLz197DjL4GjyjVC30EQg8w4ES3AnVjwi+ VaztBbLJCd4KRTwZLWpX6gnv4BSGHjmq62vLwtdKPKmb8la233RpyOhXi5hur9oWnQSx iEWDO6j4MqvY0Qf9+o8JGTSYkyOdiC3U/V1WT27dpnB4BUBMf0hNjqr79/6k8UIMFzrM 5qhg== X-Gm-Message-State: AOJu0YxtNf5vY0wLNBciEuXcFuQpsa5884j1/j4DAkdyGDsPAZ1sF0PQ L32tMjPF06OCHGdsLA3YkTLBRpf2Mntm4idpB9WvAmgNt9Cee6S5f4mf1r3NUvfciBfD5ibkZ/9 GD6gfu72ToaJU X-Gm-Gg: ASbGnctVR8gz7DVBYk7pK1zUNFEHr6pMR4I/1T+TEpUUEGh8X9IqLPj3UwQRvgf8qgm QLTUBrHoNRJ3hjDv4b7WGSqjT7uFqQbZoHu0UctQB2/mBwbWOCtSK0GDCL8vGrGEtmW/teM6fp7 nLsN6hl60mL5emXHxP1u3YDLq6hf94t05H8wo5jrIttG0QoQcnfKR0PUmQlnVNlvzPBAcL1Xehk iJUhINgos6sjHHgJSuvbG08oJFiKfTI20vlcpiiyEXD9eDEqHD2UG61vFFzUivic/i2UOK1/N7y +I9YHsgigKuywxXQwwon20rSTza49GqJFfnijnti12EzWTy579VRAJmY2aU20QT/kfMj1xe6YWw sdFAygjjVd1oQbkdV8VxDzPW+5ROPFjpUlWwyLUX9k58xBEE8Rtt+McIJXN5OKkfT74IXl3FxD/ mMu3C1wFMLyn1J6UFqrUM1ZOPitdqThHrFq48x8HCULn0CLxN2elB+2aOVCbc= X-Google-Smtp-Source: AGHT+IFM5G/bbzxpzPIwuFSkGk2FVHlqkJqBtmO8jLNiCL2XdqjT9lN9G9eZB3C/rrsWZjAWaTO7HQ== X-Received: by 2002:a05:600c:3149:b0:477:942:7521 with SMTP id 5b1f17b1804b1-477307e285dmr102838195e9.14.1762165193648; Mon, 03 Nov 2025 02:19:53 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 21/23] target/i386/hvf: Flush vCPU registers once before vcpu_exec() loop Date: Mon, 3 Nov 2025 11:10:30 +0100 Message-ID: <20251103101034.59039-22-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165237769158500 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/i386/hvf/hvf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 5134f302c08..51b3d392879 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -731,6 +731,10 @@ void hvf_simulate_wrmsr(CPUState *cs) =20 void hvf_arch_cpu_synchronize_pre_exec(CPUState *cpu) { + if (cpu->vcpu_dirty) { + hvf_arch_put_registers(cpu); + cpu->vcpu_dirty =3D false; + } } =20 void hvf_arch_cpu_synchronize_post_exec(CPUState *cpu) @@ -990,11 +994,6 @@ int hvf_arch_vcpu_exec(CPUState *cpu) } =20 do { - if (cpu->vcpu_dirty) { - hvf_arch_put_registers(cpu); - cpu->vcpu_dirty =3D false; - } - if (hvf_inject_interrupts(cpu)) { return EXCP_INTERRUPT; } --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165268; cv=none; d=zohomail.com; s=zohoarc; b=LnsHkwxKqCk3yoIPicP6LgLNu0WCdUrcIGfBRgPDa2Fl+QI74DgOM+29+lu8Qlyu8MBkKsifniRCu2c0p+mh8JzJ/SAHGDdQLG2cUSqZWO1Sheal91QIiVW6aUwSOCGVk9/pl7TvzE6g8b+l+2oWohD/jP7DLEbr81b1S99RB0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165268; 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=cAPRFLr9vuEGB6NuD3MRzbTtng8wcNEQ/2tGtl9RYyM=; b=YtFnny2O/XboBRAaqJ2BkBh/1I10bUEEomGrRtl0HbKYdIuvwhT2h0YBx/QKMOdusLoBQXIOv1vMEu/xyCdef8F7jdFxLFILRowmE8RjahKF+MlR4ZMJlzv9me3fd9yRjRIpAjN7xeNl1yWumIaVQMM4yUMSdMS/XaxQGBwECWE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165268562398.7201552606459; Mon, 3 Nov 2025 02:21:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrg0-0007u9-Aj; Mon, 03 Nov 2025 05:20:40 -0500 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 1vFrfr-0007ep-NQ for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:20:35 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrfm-0004J8-S5 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:20:30 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-471b80b994bso54922555e9.3 for ; Mon, 03 Nov 2025 02:20:24 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429c13ebfe8sm20110383f8f.35.2025.11.03.02.20.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:20:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165221; x=1762770021; 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=cAPRFLr9vuEGB6NuD3MRzbTtng8wcNEQ/2tGtl9RYyM=; b=fK0OcrQUz6BXCoWWNSlYQygeFyt/ZDcswDwmBU1wtXbcsi09DDJ4bIU3CqtlBeu+uL VKyGcV7D4tMOngLEZk81/IVyGSWWnIfJZyCGAIRVicxxx9olL71zGEAAs+BjNzVzee6S icQ9to1LX/xt2HAv8WElILgy8/TH0WCos8gT7+d52wXP63bvHXCO9efa2kMqByutGky9 nTrvYz7Hww31touVbDTFCNkJg1O3xA7Kg7gEGFPZVthDFHmTvDChqg89R/hLozc9it53 jS504nzOnxJTXfH5RRERan8CWqXmYtbq6ZHoYxzJvGCmafZuqP9jz27MKhsXTTCYaiZb RRNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165221; x=1762770021; 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=cAPRFLr9vuEGB6NuD3MRzbTtng8wcNEQ/2tGtl9RYyM=; b=QRp7oSU+xoFy6T9zsVwpd8Wp3NFudUYu6Ogom/gt3AFSKBK1lkiwFHnSjYttQEktSU YzWElVeza7wSTN78ipZe2r63eQAD+Q9GqOZSyKsYBRjMfM5/t5kP43OaaoSNjIR3jTTv aB/ifxLw9fNvyMmi8yBpzLZ/VMGzMF2GOyTudDjoTZUJGK5LhRV/vRMGMlOyhono2fB9 g2hJkTcWz3C5TEV5fT0lZGeRJXM5N+FIkS401uzOwHQEW35f9vFVb/hhyNVuJ7fn9HCA G5jtbnTvzs39gbZje8fk+KzS4ZuINnJU1E9eC6w3nhEk5kdiCXFS4DPMekSVRI8xV3oI jLow== X-Gm-Message-State: AOJu0YyuwiGr7Tz+YC1qO2OEKz/3S/4vdNiYLLcVdY1ERZD8SV0VV0+R mC2O71aaXAr641F2fVn7KAW/EGrx4QGQTeB/rQqD3KwA+k+AUBOdzcxSixPDYQNV77go4hsI2K3 meZXF+bdbZrCK X-Gm-Gg: ASbGncvJj3VXq1sVUvLe3mFr2p1XCKoG6HNJn0AOAm8KGW669XgDOcbUXjK1mkQsBgF bCFoRyj6dgDYZqBK4tX4sSVRf9kc4GAUujwq6NjNK+ibe7WoqkrnzO+ltFbFOkucs+AFUBtHCr9 HXKBHe2bXIWm6xFe+duwi704e8XC08uOKGJoewBvPil2k4VL2+pb8ZKS7bY7QjlN57vVgrX3DF0 mPLYZFhaFxC0DIroSy3BHomySXbqUKJbmhE1kLWHzPopS3Lct4g+JonLqlh7TeRsIfsfSxBBtBu RVSDpO/6Ptz0//+/XDJ9/Sg5NUVNtBp8JhMIWe41f2K8PiCekykYvAkidjmUT2q4daT909+Sx7g 4hP//K9ASEnLcZB4QdwKyB8lPiTovTe8YtEAg1JXWtH5WJLxCIy0QoXMohr6ed3gAI3Th993Som ptrxrdtGq6giAQ1Uhg1loC9ZW4CS3bw+vJcbDIWfhJhVyv/l1xjP6uDK+hzLbrc7hHXEhBQg== X-Google-Smtp-Source: AGHT+IHEoxliw9cXSsdZp0YQd5iXI7NQiNi1ypvJIzxIwL+gGSs3u8a/R+/JP6HzjWE9rlVljY4wlQ== X-Received: by 2002:a05:600c:190e:b0:471:669:ec1f with SMTP id 5b1f17b1804b1-47730791083mr125530505e9.8.1762165220747; Mon, 03 Nov 2025 02:20:20 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 22/23] target/arm/hvf: Flush vCPU registers once before vcpu_exec() loop Date: Mon, 3 Nov 2025 11:10:31 +0100 Message-ID: <20251103101034.59039-23-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165270430154100 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 8d0a528dceb..268a0bcd8ea 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -2019,6 +2019,7 @@ static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_e= xit_t *exit) =20 void hvf_arch_cpu_synchronize_pre_exec(CPUState *cpu) { + flush_cpu_state(cpu); } =20 void hvf_arch_cpu_synchronize_post_exec(CPUState *cpu) @@ -2034,8 +2035,6 @@ int hvf_arch_vcpu_exec(CPUState *cpu) return EXCP_HLT; } =20 - flush_cpu_state(cpu); - do { if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) && hvf_inject_interrupts(cpu)) { --=20 2.51.0 From nobody Fri Nov 14 18:17:39 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1762165312; cv=none; d=zohomail.com; s=zohoarc; b=JF41gs+Gbt9jEPThvxLVWDBdD9WquycOPLc5BpmK+FAI9CuiBwpue3XYXfESwCX9lJARf6KAPaUJUOaKGhicprnzzsi5sio4VtZsdRGWajsPrEkFRRKr0lt03s6ZFr3XN+g+WrHCoUi5o5b0PkEV7qOcItsrWS1H+pC1uMJbi9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762165312; 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=CufbQupGdsCIUBDT59fiOpwXVN1u/Jn4Hb62P35O8nU=; b=nsFvnTWiIly6lkxbBKi/krtrMF4CA5/8FgPo79h0EuUVg0asaXBtNLIee3gy2vvYVLCQm1Eojpvfd4DJTr6Q1TvhkUjSRUMhXgCwzQoLn6/HTl5lJSEhXv6s4pqVWkoy9ZUElB9UyiJZxtJwt219FWdO4DuhdvnSkThuCqunYtk= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762165312174822.4382288146145; Mon, 3 Nov 2025 02:21:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFrgO-0000Ed-QU; Mon, 03 Nov 2025 05:21:05 -0500 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 1vFrgM-00009E-I1 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:21:02 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vFrgG-0004OJ-Vt for qemu-devel@nongnu.org; Mon, 03 Nov 2025 05:21:00 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-429c82bf86bso1638464f8f.1 for ; Mon, 03 Nov 2025 02:20:52 -0800 (PST) Received: from localhost.localdomain (ip-185-104-138-122.ptr.icomera.net. [185.104.138.122]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429d28f2d29sm6299293f8f.5.2025.11.03.02.20.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 03 Nov 2025 02:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762165248; x=1762770048; 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=CufbQupGdsCIUBDT59fiOpwXVN1u/Jn4Hb62P35O8nU=; b=lxhU0f2N0M9yqt3176rNeIUpncbk227YvE0Auc2bPt//bemEGDMFWb3dGxvuuP/zoJ IHebshbXrpE4VeGewxhkcXdqNG1rR5Cvmc3B/l6+laOFg3ui9NDyXNn4O8l1iMtFDExQ RDCKb9jGhB0B8sof+JabwVjWm2Ux+mDpm+gYC3YV033A7AqW5ZecvJvYd0qrN9txi8L9 2pCkMR6FBwwjS2forfio8RyugDvkCeEfGRmQeeoUC01CpR808dMbR68IrY0MHxjjFRpg i9oV6vnpoAvY7xL8lXgHolrhjLLCkloCrx+TLGZbMF7lbCKOCNIirevERYFqxHEMgjB7 aqyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762165248; x=1762770048; 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=CufbQupGdsCIUBDT59fiOpwXVN1u/Jn4Hb62P35O8nU=; b=Qf8dwyb0bH8QPcFsQtjrZbmp8qRHu3M2hDqfZDb3doZGZU5i6IoVxyZdV6cv3VUwSc P3px5P7vHCmL10XdvC2aaTuJtt6eqphjFzPLXk3h9CnuNKCogFXvuc7DyoCGppbcCJIA W4/yQHmCzW0bOiAfBfy3Qza5GqmxyCnxchcW1zkR9zCXCFutxYkqTe71ogF1UHdzjq25 QOjCuD+v2UuJW0VaMpJtwGctII4zQ2v8jL0Ar9gMiGd6X8nqXMEkJ9J2C6YcD7aCoIg0 LbmxVpIbd9vD3ikkiE98jbes4R4FeTqxkZ6NBWZ3oxkPqgpT+28bQZFk5Bj8ukb9/xC6 8Waw== X-Gm-Message-State: AOJu0YyiyHA9VVhphXHK0tPn6xw7JM+2ELOfz1f6lHTb3EV7/EzwDrgc tT67Sjh3uzp4GG54bHiEt3wblffPNAAL5E7SLdCDaNUiOX/AZiGVwBIEAFKzcKKQtrBGlCheGWx Z4EJDL9A/QR2L X-Gm-Gg: ASbGncse1cfd94Tx37BM0bb7Ts35jGmTR+O+XrfLLKWUAoGEXn3cs0Cryd7TfH0p8wQ R2EIlMJkMXJffN16LvseebbUrRx4gwXZNSnAtZSylz8SofBr4TWjZUNQbI/A8UQebKN5HmIx8rm L0pYHk+e6lpDU3P/j3Phi/eFnXgXe9WWQQIdstpZiOFi3SKfvkK0yBH+Alc0xUDEsAVAJ7MMWsf VpQB1xwVMvfCqP/pzzqQnsZzoUF1IyYZbppRq6MJ+FnZ0UspXwFLfuMKeYUHQ697Zy4nV58eDY8 +iR8eqgxDB4wDih89pi8PNYDwsu98Ks2pRFWyAzxfe+A10DjcpbGvDJf0KWATcN++XpsuPWz8wO TomPHYAZzgiHuzVVNr/ulzWGMatuZsxiUP66mxIrRveHanSgNrUie+Dnl4WYaOgxaAOJMEPN0V7 +bWPNLLLxLA79iRVOLerFPnhsawuDO2dWbBBfBCWm17YP1Km5TGRKdn93UUDMw52pQwy2tiw== X-Google-Smtp-Source: AGHT+IEFvBTZvHTIbsC+/DV3U1Q5+cJ69RvjEEz+/OjhJi2BYiQHf9lcDEdbIzBJ017VkjLagnQZBg== X-Received: by 2002:a05:6000:2887:b0:427:e1bf:13bd with SMTP id ffacd0b85a97d-429bd6e1683mr11289339f8f.52.1762165247918; Mon, 03 Nov 2025 02:20:47 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Roman Bolshakov , Alexander Graf , Phil Dennis-Jordan , qemu-arm@nongnu.org, Paolo Bonzini , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki , Peter Collingbourne , Cameron Esfahani , Mads Ynddal , Mohamed Mediouni Subject: [PATCH v4 23/23] accel/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0 Date: Mon, 3 Nov 2025 11:10:32 +0100 Message-ID: <20251103101034.59039-24-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251103101034.59039-1-philmd@linaro.org> References: <20251103101034.59039-1-philmd@linaro.org> 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: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1762165314746154100 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 268a0bcd8ea..60378075882 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -200,6 +200,9 @@ void hvf_arm_init_debug(void) #define SYSREG_PMCEID0_EL0 SYSREG(3, 3, 9, 12, 6) #define SYSREG_PMCEID1_EL0 SYSREG(3, 3, 9, 12, 7) #define SYSREG_PMCCNTR_EL0 SYSREG(3, 3, 9, 13, 0) + +#define SYSREG_CNTV_CTL_EL0 SYSREG(3, 3, 14, 3, 1) +#define SYSREG_CNTV_CVAL_EL0 SYSREG(3, 3, 14, 3, 2) #define SYSREG_PMCCFILTR_EL0 SYSREG(3, 3, 14, 15, 7) =20 #define SYSREG_ICC_AP0R0_EL1 SYSREG(3, 0, 12, 8, 4) @@ -2017,13 +2020,49 @@ static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu= _exit_t *exit) return ret; } =20 +static void hvf_sync_vtimer_pre_exec(CPUState *cpu) +{ + hv_return_t r; + uint64_t val; + bool b; + + b =3D hvf_sysreg_read_cp(cpu, "VTimer", SYSREG_CNTV_CVAL_EL0, &val); + assert(b); + r =3D hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CVAL_EL0, va= l); + assert_hvf_ok(r); + + b =3D hvf_sysreg_read_cp(cpu, "VTimer", SYSREG_CNTV_CTL_EL0, &val); + assert(b); + r =3D hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CTL_EL0, val= ); + assert_hvf_ok(r); +} + +static void hvf_sync_vtimer_post_exec(CPUState *cpu) +{ + hv_return_t r; + uint64_t val; + bool b; + + r =3D hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CVAL_EL0, &v= al); + assert_hvf_ok(r); + b =3D hvf_sysreg_write_cp(cpu, "VTimer", SYSREG_CNTV_CVAL_EL0, val); + assert(b); + + r =3D hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CTL_EL0, &va= l); + assert_hvf_ok(r); + b =3D hvf_sysreg_write_cp(cpu, "VTimer", SYSREG_CNTV_CTL_EL0, val); + assert(b); +} + void hvf_arch_cpu_synchronize_pre_exec(CPUState *cpu) { + hvf_sync_vtimer_pre_exec(cpu); flush_cpu_state(cpu); } =20 void hvf_arch_cpu_synchronize_post_exec(CPUState *cpu) { + hvf_sync_vtimer_post_exec(cpu); } =20 int hvf_arch_vcpu_exec(CPUState *cpu) --=20 2.51.0