From patchwork Wed Oct 26 02:10:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 618787 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp116236pvb; Tue, 25 Oct 2022 19:26:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40Y5xljp9fJ8A+XvOEnGhytZGAXdg6OLaT1wMPL9JZqbpbIfsAPlved749AqeQ5TnGEsqY X-Received: by 2002:a05:622a:92:b0:39c:f95d:5718 with SMTP id o18-20020a05622a009200b0039cf95d5718mr32968740qtw.298.1666751217340; Tue, 25 Oct 2022 19:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666751217; cv=none; d=google.com; s=arc-20160816; b=hP4DHalV976GqtYOuV4F5dbvRtJqnhJQQEi7whq3mZZ8hIIfEktXXqzzTyfgyFxnut YWXmKFBJdzSfqIgexeYzu1KlxXmDKmq47ZaCmrNmcjNg2mAdjvcHIPGrt7X/5sXlc6je TI3q6H+svE+0tIJYC1Nf7G9S52ZVcESLAnliwagcD1J+PwTLrUVH12ZpDfrS9t+00ChJ /X/TiitaJREqcqyN2c1JuMx49Sjn2657qJM2+kN72MLOF9vYrMsRhehAfCBwx/K4EAoL 5EXiDzbrs/L80LfHT3ksef8rl9IZX/7NnvfkKoOS7T7C/Phphm+wElL5iabkWED5Z20Y VXsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=9mIARIOtcJM7HMvAJdfElLQQ8Hp1LdQ57Vsk2P28m+M=; b=tFUWk/w/i2pUBTrqQG+8jLpjrBxqBR23gKPIeXp9rc8J53IrSGWY4YNeC1bWc49NAB HICbWrS5XKZfskKz2vt+Jx8y6g3Z8TWMVcVwhzbKRsPWfSlctVfNEjAF8fqMm0kEnFK6 so28sEmJRtWs044bTmt1XFtfSQxRYoxOsybb12pmHTIP/D3gmTKTOjgEqVM/SQDEy96O vDygBM+iF9GnqH0FwBSSA0H/SoBFP1pEZookzpcH8g8TIb8ae6LOvpZpN2f85Az95Bo4 M1GeJaW4vbhkm+BD8zgC4k/HEf9mO1CdSCMAVd+VLEQsZ0mjAAg8nkM0k1SCmIQFlwNM A+UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H6cAnz/r"; 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 o3-20020a375a03000000b006ce5215fc54si2636265qkb.207.2022.10.25.19.26.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2022 19:26:57 -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="H6cAnz/r"; 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 1onVu7-0004yq-7C; Tue, 25 Oct 2022 22:12:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onVu5-0004yf-QN for qemu-devel@nongnu.org; Tue, 25 Oct 2022 22:12:25 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onVu4-0001Ed-A3 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 22:12:25 -0400 Received: by mail-pg1-x530.google.com with SMTP id 128so13467707pga.1 for ; Tue, 25 Oct 2022 19:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=9mIARIOtcJM7HMvAJdfElLQQ8Hp1LdQ57Vsk2P28m+M=; b=H6cAnz/rCHSbUukd9WRoUT31/7U9ER9wZTlvIPRxnPOr5vYfb/ItoEit3Vrf31aTdV AIijV28CcbDl+7W14qU1v26+tFlRH7hXEutBqNjMIHrmIP44hS/G8lDk5Z2N60LV+k9m FsKJwpEX5JmoMv7yo4ipqwY4dd9odkd8/M3N0dKXxut9yDGZZ6QiRG8t3Sb3cbiqUh45 2nieP5JmXxXUclnEtypO0iFvCuMCbMxXe/ZzmDJxSD21QVixIa4FrhzaTS/wVEwwykfo yReHTDKYbk+0b+jYmN4aX5oO7FsvciAuLOe4B6xIf42jqBqzY6oJCEUnFcDVD+f0sYGk Tm8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=9mIARIOtcJM7HMvAJdfElLQQ8Hp1LdQ57Vsk2P28m+M=; b=KN9gyHhq62tnCVAXC2ixgJBz5N704qSNMp/iN27e8vYiJ8Dm56L7MldA4ppKBJrRZ/ JiCc1cTcdo4UNsUTk7+Hzcqb5596h4z5c4NOxbRHAVqMj2Wra4WMxe43gwoQEssM66lp NrLPLb2XNADcwHheHVFlZY8UkisGaZNm7L2h+IImAXMLjyX++SFndku6BmVD+331nI9S 6ctrfQ4kfpjmpz16I9AJW1w3XgWJk8sXrCGWY0k04z3GrgHhrljRdhNPVBg1spUl8fb9 pUe6VBgIvpnE4lBSmRObJixIr/B8tO9DrQ4qdZ8r1+HpHF4GDG1esGviEI5/e6TUQs3o Wixw== X-Gm-Message-State: ACrzQf2KlJfNgNa+a2XfUE4wt0nv2TcIde4pg+8h9tGhNjlsNqw1MlYf jp0xLvOFDVRg/vdqKGCK9w/h/Nd5PIeJdB4R X-Received: by 2002:a05:6a00:2485:b0:561:c0a5:88aa with SMTP id c5-20020a056a00248500b00561c0a588aamr41671510pfv.51.1666750342896; Tue, 25 Oct 2022 19:12:22 -0700 (PDT) Received: from stoup.hotspotlogin.services ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id o29-20020a635d5d000000b0043c9da02729sm1897833pgm.6.2022.10.25.19.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 19:12:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 21/47] accel/tcg: Use page_reset_target_data in page_set_flags Date: Wed, 26 Oct 2022 12:10:50 +1000 Message-Id: <20221026021116.1988449-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026021116.1988449-1-richard.henderson@linaro.org> References: <20221026021116.1988449-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Use the existing function for clearing target data. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 478301f227..41b6d5fe26 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1370,6 +1370,9 @@ void page_set_flags(target_ulong start, target_ulong end, int flags) flags |= PAGE_WRITE_ORG; } reset = !(flags & PAGE_VALID) || (flags & PAGE_RESET); + if (reset) { + page_reset_target_data(start, end); + } flags &= ~PAGE_RESET; for (addr = start, len = end - start; @@ -1387,14 +1390,8 @@ void page_set_flags(target_ulong start, target_ulong end, int flags) (flags & ~p->flags & PAGE_WRITE))) { tb_invalidate_phys_page(addr); } - if (reset) { - g_free(p->target_data); - p->target_data = NULL; - p->flags = flags; - } else { - /* Using mprotect on a page does not change sticky bits. */ - p->flags = (p->flags & PAGE_STICKY) | flags; - } + /* Using mprotect on a page does not change sticky bits. */ + p->flags = (reset ? 0 : p->flags & PAGE_STICKY) | flags; } }