From patchwork Thu Feb 16 17:11:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 654063 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp86396wrc; Thu, 16 Feb 2023 09:15:20 -0800 (PST) X-Google-Smtp-Source: AK7set/B/iZCVo23qjo4rT948/mkKVK08wNzZGPIrx1uj5c5hpq4/1QKv/MSY+WzAclW70gXDY6S X-Received: by 2002:a05:6214:2402:b0:56e:fb1b:3c7b with SMTP id fv2-20020a056214240200b0056efb1b3c7bmr5047765qvb.38.1676567720572; Thu, 16 Feb 2023 09:15:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676567720; cv=none; d=google.com; s=arc-20160816; b=UeIOww1C2fljpaWYovCalgPq3uBAYNqPWYy+qaJ3hAlolt7wqCppiK+BHBlnOryyFM VeIPj1mR2LQ14xWDsGRyd2CBTbSAVxdkjwympboXfxlqKCF7/ylVAXx2FvdGJ5cTJN0m IygDXiFVAzQkvY0i63wwxWFuYd923C7wHsC7H9c1hpf+ALRFQfKb6LoQa7r13MpTBKx6 fJwyc730hgV9KUWJkNjClvUCs1LpQScQ4KIfX1teDiRRp/e+/zjeuXYSw9FZ3NDPaIFs DgfQH6bwy/ussY02hE1odv9mfWsVBolc4Ujc0vEEFRbyHJwGk506PckAWCQSwXQyUeHf 9GFQ== 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=nb5AAn5zyFKHHN1q+dOOj2I4towk0anX1Vqm7ObRW+M=; b=jn6PxOdhQ6Uhml3Z4ucrybSvQg1wT4FV7JpIO5/QJZda69LltSxPEkuQ23RlRDy3mV JWaZljV8sC23QYssprAam1EdIs8EM8i/rALovV4wtrZw2bWMWM2pyRDaam5yHdVpAwRi fxnB26vsBBDvvYoBBWb4sWhnx6jlsW2RIAImCe1Z0bRVvQ7LuR5bfsZNk/EbeGSpr3qR mHAdFdFzOJchnYwAlbtH7jGKUf+qR+EIqop5JtaPOdG7Otebpppx60NaZmX3Opyq27+C KC6G/+pWw0VUlESFKH7ZFBmBy11/XbuwAN/M0z512f1beJOhmC1ZwWoBqwpyIlUl9Y+x cLqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O0SuPXKp; 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 q12-20020a0ce20c000000b0056e89fd6590si405192qvl.437.2023.02.16.09.15.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Feb 2023 09:15:20 -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=O0SuPXKp; 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 1pShnO-00005A-U7; Thu, 16 Feb 2023 12:11:46 -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 1pShnM-0008MA-Uz for qemu-devel@nongnu.org; Thu, 16 Feb 2023 12:11:44 -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 1pShnL-0007tG-6c for qemu-devel@nongnu.org; Thu, 16 Feb 2023 12:11:44 -0500 Received: by mail-wm1-x331.google.com with SMTP id n33so2119585wms.0 for ; Thu, 16 Feb 2023 09:11:42 -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=nb5AAn5zyFKHHN1q+dOOj2I4towk0anX1Vqm7ObRW+M=; b=O0SuPXKp3pkuo21ByfCvHGxIJr/TGXLSdeC293hEpCd4wHrWHCfYmCxysQdRkDTZIk EZsfmTY6VnIX/lmSRca+U4d2VuFeZ5ITSDucW1z1SAHWGDZ8g5QOuzMVBye2e0zMuhs5 zEJDbnjpZYml7UDAUpGB89xRlKs9VBG5iRTb525oDswNIitlgM08NpPezHouho7dqSzw yENAyyfU9pFWwi5cBXUjvtnxqTGFoPcIr3JRsl9M7gbbPpd8BW4V/sYDvTfL8AwwQIg2 md7/N5duTSorhcgoFREMSrJE3/+JSDlyVweXF3dEVI0w7CWO13BcLrV3TPxt1sKuH1GL T4Gg== 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=nb5AAn5zyFKHHN1q+dOOj2I4towk0anX1Vqm7ObRW+M=; b=QwngrgTMLHpD38ZZtPz4CPEMrMy2MvsHAvdKoRmqHv/0BPEsLrSO6riSIII1WXt05p qbTlavrNJUF69jhozeML2wW64YVyE/x78ka7nY2GrRCuyoa2L+fT0ZTCepPsQAatj7Hl G7TcApqnvO5b7N2CyW0kboQyMZZvI87CWtzIM5FeLR/1Da97oObE5c4Fwhuz/iudlFTJ ljD1TbTutHMWTAlqpLCSSytdisZe5ph6PUhaCdNpVZdb+QR/MaS318rANf0Lke09htkW 3gcBT6pBlU4MJGxvGbcZvLIaMl17aQpoOrB43o9sSladzlTLPVP0KZ9tRaV61kHf3SSh fLBQ== X-Gm-Message-State: AO0yUKVdK7ecbepM/NG+ehubWu4kIb59UOxb4Gza0sNaHanxygQMUeIs uSaDVtz8q4zkgmA92g/d8YCrAMYoObpl0kbO X-Received: by 2002:a05:600c:4752:b0:3df:f7e7:5f01 with SMTP id w18-20020a05600c475200b003dff7e75f01mr5676085wmo.15.1676567502456; Thu, 16 Feb 2023 09:11:42 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f12-20020a5d4dcc000000b002c556a4f1casm2049107wru.42.2023.02.16.09.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 09:11:41 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/30] hw/arm/smmu-common: Fix TTB1 handling Date: Thu, 16 Feb 2023 17:11:13 +0000 Message-Id: <20230216171123.2518285-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216171123.2518285-1-peter.maydell@linaro.org> References: <20230216171123.2518285-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Jean-Philippe Brucker Addresses targeting the second translation table (TTB1) in the SMMU have all upper bits set (except for the top byte when TBI is enabled). Fix the TTB1 check. Reported-by: Ola Hugosson Reviewed-by: Eric Auger Reviewed-by: Richard Henderson Signed-off-by: Jean-Philippe Brucker Message-id: 20230214171921.1917916-3-jean-philippe@linaro.org Signed-off-by: Peter Maydell --- hw/arm/smmu-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 2b8c67b9a1d..0a5a60ca1e9 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -249,7 +249,7 @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) /* there is a ttbr0 region and we are in it (high bits all zero) */ return &cfg->tt[0]; } else if (cfg->tt[1].tsz && - !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) { + sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) { /* there is a ttbr1 region and we are in it (high bits all one) */ return &cfg->tt[1]; } else if (!cfg->tt[0].tsz) {