From patchwork Fri Jul 7 15:17:15 2023 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: 700030 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp3929283wrs; Fri, 7 Jul 2023 08:18:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLnUEak0GPNFnjcvHsh5X/u8qi9yp/QgwyrDGVtkdOpQYoPhBq1MunYUCmBLS3xtYyINaQ X-Received: by 2002:a05:620a:8ecb:b0:767:7d99:650 with SMTP id rg11-20020a05620a8ecb00b007677d990650mr4382956qkn.65.1688743124617; Fri, 07 Jul 2023 08:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688743124; cv=none; d=google.com; s=arc-20160816; b=PkpltcOcZUld2QT36yQDxx1XKZSAM14qGDlUoEs5OI3zI5IpumURnsSLak01Qy/Guq 4v4Zp/LdcBFIlO6L/k3tj54/FrI1KcHkdRAEzTOib/wNjWeNVhHCTyTId1eLxc9JXplh RCo9LQQpAEuqgZFS8ep9e+7X3kW1meKGAzKtG0HHKm4VUaIeh34k2jgFapr5TJ2csQd4 8arJ/wejvSoGnwBCCEmD2lm27QvvMAYWheGRTueBrATazSKcoG37+dq2VPb6WNZE29PC OVYY3IvxDwn890Wo7CzKeYFaDh8H07wTHnz1m1ym5/lFM/2BvNTD2+UN0PFF8ida3Ayd wdqw== 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=NLj6fc0nTXSo2Q6ccqQ2bRaAaaNn/Lom3RgmCaoHH/4=; fh=aRxBrgA7CrSouwdXoZUw1AmyeDG9xQchBaflhNgNTHQ=; b=ZhEy//nh7rsN2Hi4krISGW1OATBCTiMq63WBFvXDzDApoGB2museuGkUxkB+7GqL5O Gz9cMaqkwTXV5cu/b8cbo3INlikWryLmd8xLPIGGYIRpMQM///Q48Jt/zEOMBiYlBIAa 8hCGF2uFXSffyifP0Sk74tg6HyOvZ336LCtg/f8kj6hp1LYYkFTBvyTRkGWCBY6OWbEg D9jIVzfWq5NUxowES82L6ck51X+cy30Za0KJh2/ON8XMA8+xv+Ghq2XeUSzPg3YtCEx+ KXHIi2MDHeInGEOJ3vYmLdtuLewx+sRWaaVOmSxhH8JVkeSUEefgvqpIngVG1nNX8P7d t1EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GeS3mrXv; 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 i8-20020a05620a404800b00767c39eb69asi16682qko.615.2023.07.07.08.18.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jul 2023 08:18:44 -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=GeS3mrXv; 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 1qHnDI-0000xC-QO; Fri, 07 Jul 2023 11:17:40 -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 1qHnDH-0000wp-31 for qemu-devel@nongnu.org; Fri, 07 Jul 2023 11:17:39 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHnDF-0000di-Ih for qemu-devel@nongnu.org; Fri, 07 Jul 2023 11:17:38 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-992f6d7c7fbso253926666b.3 for ; Fri, 07 Jul 2023 08:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688743055; x=1691335055; 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=NLj6fc0nTXSo2Q6ccqQ2bRaAaaNn/Lom3RgmCaoHH/4=; b=GeS3mrXvQSrxuKcn/gQ9cgnPzBIwUn4iInl0fAiL1Y2kEwQJYwJyqEzHQcPJw2JFk+ 79Mq5/zxAyjj+TOMD1dOOSjTGRVjtRvgdXL3AH/ex3B7MWOi9yc9smIDECwB2BilZz0f KQHfODngHJXxg89mtvRjjhG1VFlfSB62allue7aXWXI/7HXIZbGS9YkabpU8IDeB8HR1 G7+yt6UjtRbUoRE/y87PVan4dRlppL0H4Wqo3DJLZPYyKClfnf3QzbqgVLhDCdd7eJXC aCRaJyAjqL9ysym8maOzTbsR8emGYzV3QUnGuh4xC+yhhCX95t0mz8p+NwAfx3eh9RFO XStQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688743055; x=1691335055; 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=NLj6fc0nTXSo2Q6ccqQ2bRaAaaNn/Lom3RgmCaoHH/4=; b=VYSlEViKeYUt/rPO/OM11Wb3ZGBcmmMomLkcY7Y7+n3FNg7nvi+FKEXNQbj98sivQm 98m9Lz+mIHSg6J0wfY0b709E5VXA7g5UJiajxJ7dCG4LHqlLFBekBdrRN+TR9gSL7i3K Gqgfyu45eUXqSPu4Zb5g4WrD7JAFbQNN79L4xAkirkX8Aj2DBJqIXSM0OYL8PtLgFjOo uA3en2w5Evc4C1vpvEXM9Dt9QZVQfaa3g4qThPzrZ83SGIK7OHbzqvzP7zc9G3wbVu02 zZjnYokaOx+8W85Dh8mjBhQYqZniUeKMyHQ5Kl3zPFdWz7bzqUUPUvQvRJV4EOLklefB nxhQ== X-Gm-Message-State: ABy/qLYKNIsJgffanYrNJe8RY3Xgllh2t4Ww2bNx+s3ZU9rdsSPyP0TY 5KEC7PiNUB02qz+N2pcHpz9ynp6iEVPs6P9oeDc= X-Received: by 2002:a17:906:51d4:b0:987:16c6:6ff3 with SMTP id v20-20020a17090651d400b0098716c66ff3mr4158318ejk.38.1688743055541; Fri, 07 Jul 2023 08:17:35 -0700 (PDT) Received: from m1x-phil.lan ([176.187.215.192]) by smtp.gmail.com with ESMTPSA id q17-20020a17090622d100b009934855d8f1sm2282355eja.34.2023.07.07.08.17.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Jul 2023 08:17:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , "Michael S. Tsirkin" , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/6] hw/virtio: Propagate page_mask to vhost_vdpa_section_end() Date: Fri, 7 Jul 2023 17:17:15 +0200 Message-Id: <20230707151719.70613-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230707151719.70613-1-philmd@linaro.org> References: <20230707151719.70613-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-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, 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 Propagate TARGET_PAGE_MASK (see the previous commit for rationale). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/virtio/vhost-vdpa.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 87653bf841..3040bd8ee8 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -31,11 +31,12 @@ * Return one past the end of the end of section. Be careful with uint64_t * conversions! */ -static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section) +static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section, + int page_mask) { Int128 llend = int128_make64(section->offset_within_address_space); llend = int128_add(llend, section->size); - llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK)); + llend = int128_and(llend, int128_exts64(page_mask)); return llend; } @@ -69,7 +70,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section, */ if (!memory_region_is_iommu(section->mr)) { - llend = vhost_vdpa_section_end(section); + llend = vhost_vdpa_section_end(section, page_mask); if (int128_gt(llend, int128_make64(iova_max))) { error_report("RAM section out of device range (max=0x%" PRIx64 ", end addr=0x%" PRIx64 ")", @@ -329,7 +330,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); - llend = vhost_vdpa_section_end(section); + llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); if (int128_ge(int128_make64(iova), llend)) { return; } @@ -411,7 +412,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); - llend = vhost_vdpa_section_end(section); + llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK); trace_vhost_vdpa_listener_region_del(v, iova, int128_get64(int128_sub(llend, int128_one())));