From patchwork Thu Oct 6 03:11:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 612844 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1191073pvb; Wed, 5 Oct 2022 20:15:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4E9pWq49fsToiFUsnG1s8I0aOB1gQ7SwmODOn0RfvEsjzwy84DjfwCYoa1UatmFSWyGhxt X-Received: by 2002:ac8:5ac7:0:b0:35b:b658:4b6c with SMTP id d7-20020ac85ac7000000b0035bb6584b6cmr1942685qtd.207.1665026132754; Wed, 05 Oct 2022 20:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665026132; cv=none; d=google.com; s=arc-20160816; b=Y1KEqWqyE8/ZIO0Rqo1JRb3D3mfnmNWFoL6TNlJwX8nOFvuiVChU398jThUtSXrvzD /2WIP/G3sSilhiokI5V3GczqUu06yvfq/GWxHbUmV2FaJ262tZC5LdY8wNdGTcHdyDxn zbpYWMiVEuNzR/+FHIZ8MLCwefzrNhxUm5F5cRAEw2eWTTObGPzzltqdvYwEoy2m9wBj 8Hr1b8xXTXrdA507Bur/9gD8Xx5w5RbgwlHpbFRCwMx0XIyN/dQMxHyi5QgI7m0qcCd3 RTQ/RpvG8vf6Fa+t2H358smeNZBm0m+i+tk6Hy/xM5FlWAH3tjodWOZVX44Ys1E9ygnt pvQg== 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=OimgKPWxXttsQO5Dv6OTe57j981fAqdAef8EXWzK2aE=; b=XUwaSC3Z4tLFUYoH6u0dNAxbV4JnsXs7KrnQ47FYDLsQzNAD15bEgA1PZwB0VbdDGf vpvIl0fGJa87zUrXBSOKYn38LlYimtSLO+cVN1Zf0wsrcZFpLJ2V9yQw0j29F/2zUW22 dL+H7+B8p1I6/B5xMiNdNgfxCR6MfgKwf/uVPvIhRajxHaC/+jdieZaA06j9FTfqHHMm HrAmph/V1+HTwMgBopkOeOQ4beAJRgED45RbwiB6diyE7z7Qi1NOtdTbnW1qX41pmKyQ SFXccuc9EbAj53Dd/MF9ZgA7s/GI3cT5G6E/teHzW3XOYXJbxRTWmjNVhO4s/EuWFBdm hZAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d7UW0XEM; 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 t3-20020a05622a148300b0035d4775edc2si7555396qtx.526.2022.10.05.20.15.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Oct 2022 20:15:32 -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=d7UW0XEM; 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]:59410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogHMC-0002gY-7p for patch@linaro.org; Wed, 05 Oct 2022 23:15:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogHIQ-0005xO-7s for qemu-devel@nongnu.org; Wed, 05 Oct 2022 23:11:38 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:34484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogHIO-0006zz-Kt for qemu-devel@nongnu.org; Wed, 05 Oct 2022 23:11:37 -0400 Received: by mail-pl1-x62d.google.com with SMTP id n7so564520plp.1 for ; Wed, 05 Oct 2022 20:11:36 -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; bh=OimgKPWxXttsQO5Dv6OTe57j981fAqdAef8EXWzK2aE=; b=d7UW0XEMHs3SC7qdJUnCK6h/RSp0P+EEVn9Du/CRFJe6FJzVBpaGiBZzeBRFwIGUNX 8eGXxIafTmb/Es8/NL0WhBscTXKw23arfvj/RjkdWmMTtiTEmXYqmJ1K+5MkAmFkGq+7 5irLhC+PACYWvzFHT2XnyUCESad3XIH/xh8iASE8kiA6a+Qhq1u4hOM9Wognm59QjZ4t km5bzTNNBF2KXq7EbloMp7tTABS2bRgJ6EKGLxZ9zR+frLcJGQqp7wBP8b26xC55JGL9 8gq0HhtrQrm2Pjmw0G9UhFghXtUhGjJqfxLo99T3EU2GzPcxsj4TCLDibUxLT7S+z+X7 QUWw== 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; bh=OimgKPWxXttsQO5Dv6OTe57j981fAqdAef8EXWzK2aE=; b=HpzfCrXg2kINx1cN8AuyIWrOrdqoQ52O4iJI5GtO3EI4s3rCGwSCnmVwnhgyr6l/1C YFWZmeuTmFjSj5h+9UWQkFpLgoQPO4dmBSMRGug3eDcehUWOsytBLkUrGner1p5CGtwu TzsMd9sAWjNDMAxMf3CXFa68luVB+s+dtqve7AHIxUES3U6OsTZ0woLFN1RlgO4aLTCF i1VvXDvcRkv/Iyl3urpo2H5GEAyfPJTQovIv1WZbGv5hcKdhGuCNlBsqOkUnJtEkjDHD JW2zAdAFKhh3qXRuvp9pBUtmx1I1++ZCYuANQE/Opj7D+lkxR0nP409Xg8RDI7axaSYr d17A== X-Gm-Message-State: ACrzQf0DNX0EYzWWv3NUuhmivjUQdDr7mUG+vvHYMaieFRMq4EAVoy5g 08i+6vkF/A+B9IUNZTEobfrdS1xbSJDiMQ== X-Received: by 2002:a17:90b:3146:b0:20a:f817:d620 with SMTP id ip6-20020a17090b314600b0020af817d620mr3895717pjb.220.1665025895286; Wed, 05 Oct 2022 20:11:35 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:9ad0:4307:7d39:bb61]) by smtp.gmail.com with ESMTPSA id u128-20020a627986000000b0056281da3bcbsm58360pfc.149.2022.10.05.20.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 20:11:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, laurent@vivier.eu, pbonzini@redhat.com, imp@bsdimp.com, f4bug@amsat.org Subject: [PATCH 16/24] accel/tcg: Use page_reset_target_data in page_set_flags Date: Wed, 5 Oct 2022 20:11:05 -0700 Message-Id: <20221006031113.1139454-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006031113.1139454-1-richard.henderson@linaro.org> References: <20221006031113.1139454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the existing function for clearing target data. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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 e002981a9f..0006290694 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; } }