From patchwork Tue Mar 12 20:14:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 779785 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2204343wrt; Tue, 12 Mar 2024 13:16:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUGo90UsI8toVygAw+pRC2nfuXt7F1omGAQwJ+0Ne5YEtp+j8wuOtxY77H2+X4HIocLpLY0/2N46cg6Ugl7yIZQ X-Google-Smtp-Source: AGHT+IHzbPqfK82TXSrqoU1Rw/r7BoKfKupN0BcMKc3w87rz75iK/5xy23xSbnFn8WHSAQYR3NBw X-Received: by 2002:ae9:e00f:0:b0:788:1381:9ef1 with SMTP id m15-20020ae9e00f000000b0078813819ef1mr11817050qkk.78.1710274567835; Tue, 12 Mar 2024 13:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710274567; cv=none; d=google.com; s=arc-20160816; b=0ijRErUnS+uaAOErVrXFM32cjZ4GwQvuqYl6VXelcq4m0wUUaUj+hAvIlaBmNBPGWn E1Ia+FnFqflbi9wkHHlFHsgoAA5UsPmq/0AiAJEiZlH76LJz8PUM5QHdsDWlZ25YZULi F9nLebnkPhfukfBMDPBCVDGzcpJA1wdWE0qcEOcnlbwTB1rUNyusIpVXPfwYsTP6sYPr dXz4u6qZNt84rVNmjFbuEE1iF5/B9KSEdy0VFk7Zwd8msUPRVr3X3uKbX1v0m9Xxkum5 N6LqAiHc+PKppGaS5wFmqRC9ScpEcqPfD2xQbEXnbx+Tt2hvJkRSEDBQpsVxXk0/xeOt 7isg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gs5HlW/Ip3qFcJbnSXOPguk0JHRri5DnrCS/iUDagd0=; fh=7UWA2RRneThTkX+dTrZkoV4po8/WMFgf92effoPAD5Y=; b=tE6oA/bkvhe632Wlf7hfTZCLKEbkL2pk7PdPSTutBCuEB1W0v5btZ++PTUF8HWkOTe 8MiN9rpGuT897dsV2H1+fQvrqM2/P+S4a7vldldPp5mhuhQ2DzF7Dk+datULlPFQk440 0bY7reIoZr9kPii9/3SsYaoMOjWXYoWLWSmGZ5mktVJFbE5Fn4drf1NUDbesyfxpJRyG phxtGPmg5NGg5TlyCIsAcYAsxE/i+4z2KbSAnmRZM+6hsp5mBoRO+Tt12NWxNE95mntC k3Xy9eXOue6J0Vai2Iy9bNiUZlITyByX6FKG8Y2SmFq/8gQ+ymqjqd/3L869ICprbfZd 746A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kriJGLY/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z23-20020a05620a101700b00789773dc7bfsi1358081qkj.647.2024.03.12.13.16.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 13:16:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kriJGLY/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk8Wx-0001mM-BR; Tue, 12 Mar 2024 16:15:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk8Wq-0001ly-AU for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:16 -0400 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 1rk8Wo-0001LZ-5W for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:15 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4132f780ee2so1408525e9.0 for ; Tue, 12 Mar 2024 13:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710274510; x=1710879310; 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=Gs5HlW/Ip3qFcJbnSXOPguk0JHRri5DnrCS/iUDagd0=; b=kriJGLY/pDR0v7aiAz4MkeEwo//oQNgN9BAJakpBYKJx0AC8+b/QDThdK31LYWTcec V1tqRojKl105VqCVekvp43VAJqUmpSU0dvyySE4w/d5wGx4nQA3XcFZb5q8z5SOjgrn/ 41GQieRG+Aeu+TV4bfvlEVK7qg6Lzg96YLmW9+iGzE4XmT1XSgTDLLACVTP+CC9QaBTC fVjsNPJtr7P5Bg/BlesN61z1GlUvqzBv07ZW2R1T2gIRidixLpqQe0dB9R9k7dqWl14B rrtd2qCDEDAJj3HChTr5+Wayc6rY8dIzZK1pAmma2whfWpBhRxCG28AXloKb6c76SNt0 QWtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710274510; x=1710879310; 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=Gs5HlW/Ip3qFcJbnSXOPguk0JHRri5DnrCS/iUDagd0=; b=NR6Tkks4V3HkYRlQ1bSkD0rfcQjErD3rsNmKd2c0BamGWi2aYF9EjIJrrKieJ0SVjc ujdT1sRpLuvukhIFOckUSMYlTqEZhZvLXuabutE3pn7YYLk3nSb3NRiEZKD2KViRcOf/ OzICF5Ksm8rMFMsWzyH12JUaTt0ElBMmZmtYuGCZRQ0rthLeTF8JVX/KF8Go6baFpfNO dSl6SqSYalagaoaOl700Sf//7n/neUoG+NVSWSI+u9EnRp/1xlc7fqd7R1masQfIBYZr CNPc2oUZHHanTaS+1WP+79cmT49ASYNbQ/G6DtkFV+/ums07uSAjYcE1peUacJJd4N/j /blw== X-Gm-Message-State: AOJu0YzyJyTVoPzCpDUhfqXm0AkwGnalKv/Kfwjjr7bzgqmZpYMRUpib r94qsh2T+UaZHrZv9kMGo4gcUvuUkdBxG/Ab4vyA/FlO626EgjY4pW8W87OZ86DMqRAlJwQ/vL4 g1cM= X-Received: by 2002:a05:600c:34c3:b0:412:c379:606 with SMTP id d3-20020a05600c34c300b00412c3790606mr534888wmq.2.1710274510026; Tue, 12 Mar 2024 13:15:10 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.139]) by smtp.gmail.com with ESMTPSA id s14-20020a05600c45ce00b00413177c3f1dsm13194769wmo.18.2024.03.12.13.15.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Mar 2024 13:15:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Richard Henderson , Nicholas Piggin , Peter Xu , Paolo Bonzini , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v2 1/3] physmem: Expose tlb_reset_dirty_range_all() Date: Tue, 12 Mar 2024 21:14:56 +0100 Message-ID: <20240312201458.79532-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240312201458.79532-1-philmd@linaro.org> References: <20240312201458.79532-1-philmd@linaro.org> MIME-Version: 1.0 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to call tlb_reset_dirty_range_all() outside of system/physmem.c, expose its prototype. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Nicholas Piggin --- include/exec/exec-all.h | 1 + system/physmem.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index ce36bb10d4..3e53501691 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -655,6 +655,7 @@ static inline void mmap_unlock(void) {} void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_set_dirty(CPUState *cpu, vaddr addr); +void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); MemoryRegionSection * address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, diff --git a/system/physmem.c b/system/physmem.c index 6cfb7a80ab..5441480ff0 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -819,7 +819,7 @@ found: return block; } -static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length) +void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length) { CPUState *cpu; ram_addr_t start1; From patchwork Tue Mar 12 20:14:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 779786 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2204354wrt; Tue, 12 Mar 2024 13:16:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZB39DJh0OOcYtVNfZ/behSG1YRa3tIvASaYRaEEr5gKQYicALJKe/Y/gebZtVLRRPV9tCQ+e5Zd1kO9twRFaM X-Google-Smtp-Source: AGHT+IFRN6lWHAwaEQIR9Rx0fSOgnH4g1q6MthMu/VR9rfDeYWKz5ASA/wuwSQFBb227RhollD1Z X-Received: by 2002:a05:620a:25d6:b0:788:32cb:929e with SMTP id y22-20020a05620a25d600b0078832cb929emr1374365qko.52.1710274569153; Tue, 12 Mar 2024 13:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710274569; cv=none; d=google.com; s=arc-20160816; b=wmaHwOL14dIyFuHXOwBnjzkDJa4cEnARl6oTx+Z9wDffgo8fj3Ip9HnN9yKBDvecx6 lKu88yWtuo3oco+IJ5YkinxTmjfTEjouAxyTQNRL1+lXwS8BZj0xxa66dvwFWNmHDm+G m0YpLtf802NNKbxD6GVwnkLkYN7tNxHMrpwmdmDOex9bGpqu7H6RlsaIfjNdpe93AswV DIJtx2lhO5K+RCAAepLyOiFs2M2SxJi4mK7O5KPb84BQZRd+qlRtlgKVUbxVvVZKM3dT ywT7Abk6XFSbdDrVc5cyfbJDWx48JgrY/zlK7SOiVsmhq/tk+ynEA87TdG+hf5siNrKk bL2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5VoQ8jbg5bbRds0jLIlJJfwZ5fmmJeECGQ91KyYNz/g=; fh=7UWA2RRneThTkX+dTrZkoV4po8/WMFgf92effoPAD5Y=; b=Y6uuueUvfOca8Cy0RSYxo+b14lqXR2ix0VOkJ5TMWWOgspwWmpyTs1o0JLnvOTHAzv qfnloYDoAi4zgoCAaUupgyr1miSsRb7KLMfWiXBKl7/Y6uMIKa6CbHU3CF86iSjg+uDg 2vTznYHNXTKKQS5YzOWDFnKEDvpd3O2ni9+fqWvchtGM5edpXkU50GKqNCs458WXYSxY FsssOajnTZcYNqa/s+P9QjPhakjmph3TwhVEI8SQ7u1bEOVhMzqY/o41wVWjLemdagR5 +soLuGmCVW+OT1iwxQQE07tJY4fqGMuIYMbmdz1LEzYONQ7AmfW+DKd8vG4Bh1gh2QpO CqPQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rKETpona; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id wi22-20020a05620a571600b0078842187dc3si8132718qkn.669.2024.03.12.13.16.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 13:16:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rKETpona; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk8XG-0001pj-Uc; Tue, 12 Mar 2024 16:15:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk8Wv-0001mI-Cg for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:23 -0400 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 1rk8Wt-0001Mc-5O for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:21 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33e99915809so2055311f8f.3 for ; Tue, 12 Mar 2024 13:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710274517; x=1710879317; 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=5VoQ8jbg5bbRds0jLIlJJfwZ5fmmJeECGQ91KyYNz/g=; b=rKETponaFzRC8+kBF7YBsdIkyS5kKPzzum7bP5Y19LVOwn7nBARbw2MHzoicwA0jue iwjjTjr1Jtp7iwB3OVo4wsbqnovyx44OKihBTubA7V4BXyw1KG4vWTcNZj8Hl00SoGQB VaCY/kbSBkjQGsU3YdHIHhITZRz9gbEUsLt82P+c24Ajz6Be9fM0astTkbhxM9Yy0VX4 +bpaRUGxfAGZiSGNkDjOeffT4bBIDyZOsxGMlyaOzt/e7LOUOh0E4daogCgSNyq1dF2Y /LhPKWFjixWsPxb4aK44y/2jbUoRDZBC2ydP1LTStIEspOT6eZGVZMm9w7Cj1YKjHEP/ 0skg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710274517; x=1710879317; 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=5VoQ8jbg5bbRds0jLIlJJfwZ5fmmJeECGQ91KyYNz/g=; b=HqDVlWwjacHQuE0wZSqYrM1o5/WKsCQ9QBxl5uCkY7+XJhzXhS26tHX+RfOQJ0fX4b Bf6FF3e+1gX99B/1aQP8H/DR4s7Nvxf0qziZCNploXDhcQL+iHKQ9sHTLH3g49JB3Ucg uc0Z6sNSoZ+lcYJ7nJo/fMlMrvhY/X/v///K/ARRCEECMBHzfJjN8K0GgGb2qNa1FyN1 EBw9BW99fxnAWpckWkDIpUJKq1nzRTwiKfTiMiBLqu7MnWjvPy4wF3Ve0Pzv/9ugEpXd yWVH7+j0G1V/jOtKChEE1iuYmBbbWZu2Q3BLU/3viUIzeQkuCx1cT7GD7hgICcBrwSHt IFRw== X-Gm-Message-State: AOJu0YzCG+jVOpeYcpvXzptTr/kkMsf6grJV55T3p9sd4NNnzzJK8Mj1 rNW1Md2SrqrahUtC4CEbxUgEAsyLmE9YIgPKDL2ToXkjqvRVLVnOZ3EJtXnLPJCxUR6DGKcL+IX RZus= X-Received: by 2002:adf:f305:0:b0:33e:7f5c:7a9c with SMTP id i5-20020adff305000000b0033e7f5c7a9cmr381053wro.35.1710274517042; Tue, 12 Mar 2024 13:15:17 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.139]) by smtp.gmail.com with ESMTPSA id z4-20020adff744000000b0033e7910ae23sm9819864wrp.49.2024.03.12.13.15.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Mar 2024 13:15:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Richard Henderson , Nicholas Piggin , Peter Xu , Paolo Bonzini , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v2 2/3] physmem: Factor cpu_physical_memory_dirty_bits_cleared() out Date: Tue, 12 Mar 2024 21:14:57 +0100 Message-ID: <20240312201458.79532-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240312201458.79532-1-philmd@linaro.org> References: <20240312201458.79532-1-philmd@linaro.org> MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Nicholas Piggin Signed-off-by: Nicholas Piggin Tested-by: Thomas Huth Message-ID: <20240219061731.232570-1-npiggin@gmail.com> [PMD: Split patch in 2: part 1/2] Signed-off-by: Philippe Mathieu-Daudé --- include/exec/ram_addr.h | 9 +++++++++ system/physmem.c | 8 +++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 90676093f5..b060ea9176 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -25,6 +25,7 @@ #include "sysemu/tcg.h" #include "exec/ramlist.h" #include "exec/ramblock.h" +#include "exec/exec-all.h" extern uint64_t total_dirty_pages; @@ -443,6 +444,14 @@ uint64_t cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, } #endif /* not _WIN32 */ +static inline void cpu_physical_memory_dirty_bits_cleared(ram_addr_t start, + ram_addr_t length) +{ + if (tcg_enabled()) { + tlb_reset_dirty_range_all(start, length); + } + +} bool cpu_physical_memory_test_and_clear_dirty(ram_addr_t start, ram_addr_t length, unsigned client); diff --git a/system/physmem.c b/system/physmem.c index 5441480ff0..a4fe3d2bf8 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -881,8 +881,8 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_addr_t start, memory_region_clear_dirty_bitmap(ramblock->mr, mr_offset, mr_size); } - if (dirty && tcg_enabled()) { - tlb_reset_dirty_range_all(start, length); + if (dirty) { + cpu_physical_memory_dirty_bits_cleared(start, length); } return dirty; @@ -929,9 +929,7 @@ DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty } } - if (tcg_enabled()) { - tlb_reset_dirty_range_all(start, length); - } + cpu_physical_memory_dirty_bits_cleared(start, length); memory_region_clear_dirty_bitmap(mr, offset, length); From patchwork Tue Mar 12 20:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 779787 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2204456wrt; Tue, 12 Mar 2024 13:16:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzblbPSEPC/RTxMfuxVHD2HEKVw3Bznq+5YQJ47xyULOwtNMZwk/hk4tKfu2hrh7A7A3O1DkwiYIeq0mAjngpu X-Google-Smtp-Source: AGHT+IG4Nbr1HDIbnZJdpZgKHoX+NLT3UjqKqLCvWHUyUR6CQzCubj30A//E63xasznJzCFohoTQ X-Received: by 2002:a05:6808:448a:b0:3c1:e580:12a with SMTP id eq10-20020a056808448a00b003c1e580012amr1589608oib.38.1710274586172; Tue, 12 Mar 2024 13:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710274586; cv=none; d=google.com; s=arc-20160816; b=Q5vVAtHkHZBZ2Dp1Ppxs5apNWn93FffyIm9IokidTCuAiuR8QlkZ48Si2QMGnR2wIl UD0IM/bIkHBM9fh2gXA3XNn5AmoYwte8kBGCmSLYlElUTCITlGrRJTq6BTaptlzYdBU7 zd+XkT38rRi2Z6cngPxaHKsjXkKuJu5Lx8JEE+AZjnNWK8gz+e5uUUmgpop8HF5LO13q +3TRsRiqyGYA+ILbditEV4Kr29NoUctPB6OJ5+PEkRqL91XyUl7bIMlmGYImhaFIDOkY tvC52Fgce9deBuo05sr/jmoJNkS49tYS9dzNvx+3FVlAajtagbnHh78n5fr7xxPUZJDg jyXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eKgsu7QFjVLGSprUDHjOGJwaVzxS/YEnXMOQmjF1L3E=; fh=7UWA2RRneThTkX+dTrZkoV4po8/WMFgf92effoPAD5Y=; b=qvo6gfh62NdxUcbTyUcTANEdTUEpMzp92Hl4QXlb4qM6NSLQ7PZ/MAZbLcK14Yole8 y/MEX5Pxwh7CveTkTIEpc23H8VZQksaDG1MVAkpL3RCnHmAQqzMNjzJK25/AxUxwYY+h ubDZ1OrUobVNgzWUqKBnEPG0iSWs6q2gFQycS1x3Zuh+oikuhgfHjvd9CEs3KSDrrmgg 9AQqin3Huj5eBEvixM2s0ZM0XrTl0wZa8qjzBHRHYTbaHLKPfQ7bmdOZzD2O0ZVAPobZ ctO0zUveKJGM7cpUlqDPz8GAwLt59G5Dmci0egIOLAKRgXmpOxr+EoNHTn1rSqoZDe9W 0Idg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NciexrSE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f12-20020ac85d0c000000b0042f512f97afsi3267785qtx.780.2024.03.12.13.16.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 13:16:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NciexrSE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk8Xb-0001rp-DN; Tue, 12 Mar 2024 16:16:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rk8XE-0001py-O4 for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:42 -0400 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 1rk8X0-0001OY-1i for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:27 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-413e613316cso2475315e9.1 for ; Tue, 12 Mar 2024 13:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710274524; x=1710879324; 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=eKgsu7QFjVLGSprUDHjOGJwaVzxS/YEnXMOQmjF1L3E=; b=NciexrSEsXlrPIvX0KYN7uoJn5DN5ULnl+I9bFF69sGluT8jLXfPlSfhMX/w4PBh8p 5j97wiUlpoBSHTXKFJMCdYJ9TZ6I7u1N5/YrDu6SZGG76r4nDc9RPout611EEazyerTE et5xeT2m4BOUXHJXRRm4bn7SP5ld9lsUVTZ2h7xkg6nMgi49rCX/bK84UrpYmLoTGHT1 QzC96OoMPT+vNl14kI0yguHf08A/lxoYDbjtr61or3v/tu3QKR58Ks73ztWoQiYclabe jSSYKHN6mcp6GLb8sJTcj002V9kjmn+PwpI9IBGPhEo8qhcc4Fb26Lpq93hJ3hPK9en3 hAeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710274524; x=1710879324; 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=eKgsu7QFjVLGSprUDHjOGJwaVzxS/YEnXMOQmjF1L3E=; b=kzUA7YdvX0Mh3VFLtGqlQaVPiFPX7KYC4fVVHOBv2kyH2wXd1JyKmPiXBb0ecT5u7R sCuMPkLzopx0sOTAb24EFMDslCCxQwpYJEbDDZyA9OdSD9j6BBpqK7j/d2YA/2dAlZnF qTnm/G5fWKWtqfb7/JdsEOU+SvKplN7MN2Xl8iKyE+PlrpF73kJoi2i5NEFCjruz+HIW OV4qpKaWYSIKmFJ5Q8ca4rMwx5SIL5KyMCK+mPpmQToL6tKf2a/GpYa9Xs+rIIFcjsom PWGg2MAiN+QYaEmjFkt0pwXy0Q0TLOBXoGb9UQrUgAZwbG7nmWzUl6CqY+ywvonDjMIJ TYBg== X-Gm-Message-State: AOJu0Yx3vfY3L22NjcoggHF8MDcFyNseZ5KrOSh0jBHTcZfCHQdAaJ8D rTvQ3n+pk/bIpw3GbC3bN0GuOl2Uv1KtsLOJBI2vzWEPnoCZ/EBYNw8+dOwFJfhFn2czjdVs/ZK rf28= X-Received: by 2002:adf:e445:0:b0:33e:7cc6:9936 with SMTP id t5-20020adfe445000000b0033e7cc69936mr305337wrm.21.1710274523950; Tue, 12 Mar 2024 13:15:23 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.139]) by smtp.gmail.com with ESMTPSA id q18-20020adf9dd2000000b0033e90e98886sm7230234wre.71.2024.03.12.13.15.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Mar 2024 13:15:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Richard Henderson , Nicholas Piggin , Peter Xu , Paolo Bonzini , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v2 3/3] physmem: Fix migration dirty bitmap coherency with TCG memory access Date: Tue, 12 Mar 2024 21:14:58 +0100 Message-ID: <20240312201458.79532-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240312201458.79532-1-philmd@linaro.org> References: <20240312201458.79532-1-philmd@linaro.org> MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Nicholas Piggin The fastpath in cpu_physical_memory_sync_dirty_bitmap() to test large aligned ranges forgot to bring the TCG TLB up to date after clearing some of the dirty memory bitmap bits. This can result in stores though the TCG TLB not setting the dirty memory bitmap and ultimately causes memory corruption / lost updates during migration from a TCG host. Fix this by calling cpu_physical_memory_dirty_bits_cleared() when dirty bits have been cleared. Fixes: aa8dc044772 ("migration: synchronize memory bitmap 64bits at a time") Signed-off-by: Nicholas Piggin Tested-by: Thomas Huth Message-ID: <20240219061731.232570-1-npiggin@gmail.com> [PMD: Split patch in 2: part 2/2, slightly adapt description] Signed-off-by: Philippe Mathieu-Daudé --- include/exec/ram_addr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index b060ea9176..de45ba7bc9 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -513,6 +513,9 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb, idx++; } } + if (num_dirty) { + cpu_physical_memory_dirty_bits_cleared(start, length); + } if (rb->clear_bmap) { /*