From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32790C43461 for ; Thu, 10 Sep 2020 14:23:24 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B602F20BED for ; Thu, 10 Sep 2020 14:23:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yFEPjAjh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="cb3uloxd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B602F20BED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yUAcSN6qnHzSrhN1pD2bNiK4cwb4iVMxkg9wG78eos4=; b=yFEPjAjhh64VxR50U7YyutI6n UtI8ObC94RB22l4uztgd+TrTbomh62qiNJX0psrzMkrJqw/s7Sb8p4HzovmBXBv9e48qzlVxoEVAB M5nZlRsTPa91Zy0drzCCcovY+yhU0jxuR1tzgv4KL8vGn08TI8oLDnsrMKZnVk5edU70Z3WXPLRAw UbHvv7u9w6ZIxLG+hJ0z5DCiwFs3cE3PTdSDs+wni+ANoNKj2VFUskT/AFmyDHr/x0IdnvaEv9B5m OiklsYyE2yMRj3WWfDDBpMTeUlureBkw7i9jh8gh47kGuGiBtQuLfl4jdHyjVW46JSNTdJ6SIju4w PBpSGS9Ug==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGNSh-00072E-V1; Thu, 10 Sep 2020 14:22:07 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGNSg-00071l-1z for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 14:22:06 +0000 Received: by mail-wm1-x344.google.com with SMTP id a9so230475wmm.2 for ; Thu, 10 Sep 2020 07:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=faHnn3MDZ+o9Yt7AhxvgCkCqk4LhPuX7FJChBWAArPk=; b=cb3uloxdvwDRe1Sjp2o7cqbmLdkpq2ufE0pjVaV1dWp5qCvy5zlFIvhpm883bFnLIT 1q4QTgYiVhnSxHVJTyfNOU6smrDj+oyO2cBAh3N8iOiZWI3l25SUciqg9ZFltGfmr/QX Ujw4WvAbxZJQ+KKu6L4R0KLT0yJGXyTXIAJcwQ6B7OYaz64MMko5jJ1/maUiAiGLtP22 M/zfmMDq4Xpvurfwazz0NLIZn2eTmAADRcSDSNbI/n01lYf4PKFMv64ST1d9NM59dYaw rod3ewihgvQwnjVwLZL502kCEM3ajgLG05sm0s+qcLpNiTSAt63eX34YkrpCd4icYYc+ PExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=faHnn3MDZ+o9Yt7AhxvgCkCqk4LhPuX7FJChBWAArPk=; b=QGyxcSksQd0vGl+4jB5QoW3pqZzdbamDfEzKq19+3p3fPKyAjHiwBGPZQ/ciL/FLLr YB51AKT+soEo7rEjflYCyBPilXURQwuBUhc5xGyZNE0WYTCkWKNMBaE8H9Kgrl85qW7e bjmsclWxJr9CCTtcPXAL0fIooza5vhrzTgSoxhZK0ZO9tL9EaDZCP6AAT7yD54f+2W7I q1AbUk/ya2MNWMBi/Y2rPgkgi9MT2xcwSvbg7oOQ6MH3a3FQVuyiAj1uXI3SU/aj6hw+ YUQSZDaEYlpH5bOgQVpBT1iOZFl4r+sJeX1kE7frGHYeL9+PnPSm459JlMFK61iYdY0T hXSg== X-Gm-Message-State: AOAM532ZcCXTlNBbIjJbOH6rV5x+eNhauj5wPu5RkjIIuKXXkooDzacx GvDggoKSRMumY/i6+5J8lTCJPg== X-Google-Smtp-Source: ABdhPJy1RpoPFKJBj75sNw3IPmQZKuNc0NIWCWdeXX7q+xyNsbP63rvzsXVnG2fdXWLtmVOPSbWbzQ== X-Received: by 2002:a7b:c3d0:: with SMTP id t16mr200648wmj.169.1599747724967; Thu, 10 Sep 2020 07:22:04 -0700 (PDT) Received: from google.com ([2a00:79e0:d:109:4a0f:cfff:fe4a:6363]) by smtp.gmail.com with ESMTPSA id c10sm3851717wmk.30.2020.09.10.07.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 07:22:04 -0700 (PDT) Date: Thu, 10 Sep 2020 15:21:59 +0100 From: Andrew Scull To: Will Deacon Subject: Re: [PATCH v4 02/21] KVM: arm64: Add stand-alone page-table walker infrastructure Message-ID: <20200910142159.GF93664@google.com> References: <20200907152344.12978-1-will@kernel.org> <20200907152344.12978-3-will@kernel.org> <4ef01cff-71ac-7f3c-2404-af184f5a5cb4@arm.com> <20200910123712.GB18100@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200910123712.GB18100@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200910_102206_136411_A550475C X-CRM114-Status: GOOD ( 21.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Gavin Shan , Suzuki Poulose , Marc Zyngier , Quentin Perret , James Morse , Catalin Marinas , Alexandru Elisei , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 10, 2020 at 01:37:13PM +0100, Will Deacon wrote: > On Wed, Sep 09, 2020 at 04:29:26PM +0100, Alexandru Elisei wrote: > > On 9/7/20 4:23 PM, Will Deacon wrote: > > > [..] > > > + > > > +int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, > > > + struct kvm_pgtable_walker *walker) > > > +{ > > > + struct kvm_pgtable_walk_data walk_data = { > > > + .pgt = pgt, > > > + .addr = ALIGN_DOWN(addr, PAGE_SIZE), > > > + .end = PAGE_ALIGN(walk_data.addr + size), > > > + .walker = walker, > > > + }; > > > > If the caller wants to walk [0x500, 0x1500), for PAGE_SIZE = 0x1000 (4K), the > > function walks the range [0x0, 0x1000). Is that intentional? > > Yes, although the caller specifies a base and a *size*, rather than an end > address. As a concrete example, much of the hypervisor stage-1 mapping > is created using PAGE_SIZE mappings of random ELF symbols, which correspond > to arbitrary addresses. In these cases, we really do want to round-down the > address and perform a PAGE_SIZE mapping. I think Alexandru has a point here. Turning his example into something equivalent that maps a random ELF symbol: struct some_hyp_state s = { ... }; // &s == 0x500 // sizeof(s) == PAGE_SIZE kvm_pgtable_walk(&s, sizeof(s), walker); Given `s` straddles the two pages, the part in the second page won't be mapped. Should the end address instead be calculated as: .end = PAGE_ALIGN(addr + size), > > The alternative would be to return an error if the size is not page-aligned, > but I don't think that's really necessary, especially since we accept an > unaligned base. > > Will > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel