From patchwork Tue Nov 22 16:39:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 627510 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2577139pvb; Tue, 22 Nov 2022 08:41:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf61zNBI1+6f1oWDUgCN+Yie3F0lRJaJigDMzv1UZJ6LCXyG8GPRYgmM1xPK7ss/rMOfgxJs X-Received: by 2002:a05:6214:3b01:b0:4c6:21d3:d074 with SMTP id nm1-20020a0562143b0100b004c621d3d074mr4388855qvb.126.1669135264691; Tue, 22 Nov 2022 08:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669135264; cv=none; d=google.com; s=arc-20160816; b=c90jUp9HhnTmhb926HmVmDfH5iMdSJHRz+I7Q/Mi7ydkeGujygxfIp794hBote5MPa fx9Ikm2ijdpEdXUfE0cesqikV3g23dTSXLHxbogUSxXSNGTZoh7Nl2lea8fmtn/lEZSH UzPSWEXpFADR2Pn9eca7o+aVevJbWiHaioUzLF1Vu81O9Gs2BBdytB8+p9GoMXPqvf7S Yo3IJyz6fjIGtdhOy0XuP0oj1rI9MlrHrXqFuSNqHZm6uZpS+q1GPHRl5tZ3usHzd6/W 2mFuPqYLOyQeauJfSxOgxx6JW9ivOukLNpOm6G5YFLK6u/DVmnRXG7eVO0EzQSOc+d+Q oS9w== 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:to:from :dkim-signature; bh=HqDPpnWELHr2m7elwL0yB9WHHm7yHlEKuLIM5l4oojA=; b=XsHHEywi8qRrOlk2oTJSBTOOAn280ClcyfNTjO0mlSDRwETxNIhNGhfYY9NWzmjJUb tVjl6ECUzI20wBvyWj1lkeRNRvr52ctXuPm7X7P+20O2cWswdu12XplBeY0uemEysLX3 /sokmZ9gJne64tK/lQIjTWhjQMwl7/sr4Z5OlYaOqxJHxG37BQRAPGle+fytLmHKhe6C CQZyQX59HKK/fijZ6a3mA+0JWX019U+GOW+40tHYc0GztV9uIimWhzzvD20H/8vZaYar TmvTK2+nXnjdb3sHDdBQYGiTr5sCdgpJiPGPIq4trBft/jYksdlfefIH1XP9pntVF/9S TNEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ML/oFIuA"; 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 r13-20020ac8424d000000b003a4fafe2594si7573840qtm.556.2022.11.22.08.41.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 08:41:04 -0800 (PST) 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="ML/oFIuA"; 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 1oxWJj-0002Hp-9X; Tue, 22 Nov 2022 11:40: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 1oxWJX-0002GQ-9Y for qemu-devel@nongnu.org; Tue, 22 Nov 2022 11:40:03 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxWJT-0003nb-G2 for qemu-devel@nongnu.org; Tue, 22 Nov 2022 11:40:02 -0500 Received: by mail-wr1-x433.google.com with SMTP id z4so10990775wrr.3 for ; Tue, 22 Nov 2022 08:39:58 -0800 (PST) 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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HqDPpnWELHr2m7elwL0yB9WHHm7yHlEKuLIM5l4oojA=; b=ML/oFIuAVEeanFtQtlzUzlU2mfjKw55JkQMX6vyJAa6Suh4VoG5Z22UIPB+dsT8N6b dMHnwnrnCMOvxNbSmQKuEbll2i3r2azAUf3sXjzxP9RbqtQ/G//RWFr8Jqbh0G3vXgIX jsBoouhipahyu1o4OE8tW+hkonm0yVKjcXplvO0H6vNJt/pWgbjrv2kcukXXlnkEsOqm 3kNL1u0bPp3mFb0UlI9MeZUeYYCJyDeTlVRgol/OndeqkSaHKzYSlcBBL0z/YGrnK0hw 8fucL1PBStmqE4HiDCuaZ2TgK27VARIKXYDvhJVC2EFyMxF1ZGjnhJdackZFSFvXp/SS jt7A== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HqDPpnWELHr2m7elwL0yB9WHHm7yHlEKuLIM5l4oojA=; b=7rjCSdUuFNxGhaP8MngxBIHExprZVUblxS4uxHqfqVjkxhpsQoF5cWWA3bJ+gUynkK OAKxr2F7Vz6Zn0dgDIMAvgIlNylgMseg5w8SSXEtb6mF2N/kHH/TnBdYHxmG/EfSTG2y 7Kv5nWQKOX6wXWd2tvdVVU2sdrdJ3fvsdiNIH4+uHcygTU5ZCJ6f/d9uZViL3IlHyH8U eqbCo80+5YOTFlkGRmyw3ffRJMAPyVSEMwzohRqeutLaVN+hMZKz3Zs7urHY1esydbCu owfRPZwjAyKQHPd/418o9rgz0DEg7fn+vS4XDAcsOQc0UZsMBNtHQt2QO1RwOHzhvZB/ Rtlw== X-Gm-Message-State: ANoB5pnrzw7L9uNZWevonerzr0VJaQUplvCZFHsa5iHQ84eMZDDxua0b WVSjN0CxUIuIJ6DEfadE5kZZt0kih11y/Q== X-Received: by 2002:a5d:4c8c:0:b0:241:c222:e27e with SMTP id z12-20020a5d4c8c000000b00241c222e27emr10328767wrs.236.1669135198016; Tue, 22 Nov 2022 08:39:58 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id l10-20020adff48a000000b002366ded5864sm14353585wro.116.2022.11.22.08.39.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 08:39:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/2] target/arm: Use signed quantity to represent VMSAv8-64 translation level Date: Tue, 22 Nov 2022 16:39:54 +0000 Message-Id: <20221122163954.1900093-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122163954.1900093-1-peter.maydell@linaro.org> References: <20221122163954.1900093-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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-bounces+patch=linaro.org@nongnu.org From: Ard Biesheuvel The LPA2 extension implements 52-bit virtual addressing for 4k and 16k translation granules, and for the former, this means an additional level of translation is needed. This means we start counting at -1 instead of 0 when doing a walk, and so 'level' is now a signed quantity, and should be typed as such. So turn it from uint32_t into int32_t. This avoids a level of -1 getting misinterpreted as being >= 3, and terminating a page table walk prematurely with a bogus output address. Cc: Peter Maydell Cc: Philippe Mathieu-Daudé Cc: Richard Henderson Signed-off-by: Ard Biesheuvel Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8ca468d65bc..f812734bfb2 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1172,7 +1172,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = ptw->in_mmu_idx; bool is_secure = ptw->in_secure; - uint32_t level; + int32_t level; ARMVAParameters param; uint64_t ttbr; hwaddr descaddr, indexmask, indexmask_grainsize; @@ -1302,7 +1302,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, */ uint32_t sl0 = extract32(tcr, 6, 2); uint32_t sl2 = extract64(tcr, 33, 1); - uint32_t startlevel; + int32_t startlevel; bool ok; /* SL2 is RES0 unless DS=1 & 4kb granule. */