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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 D0364C07E9B for ; Tue, 20 Jul 2021 11:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEAB86113A for ; Tue, 20 Jul 2021 11:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234265AbhGTK4f (ORCPT ); Tue, 20 Jul 2021 06:56:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232210AbhGTKzt (ORCPT ); Tue, 20 Jul 2021 06:55:49 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECFC1C061767 for ; Tue, 20 Jul 2021 04:36:26 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id f9so25619784wrq.11 for ; Tue, 20 Jul 2021 04:36:26 -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=d5WGGczUDQ+z5x6mRYmC5MZD9AX2DybKW9Ucl1ZZ5x4=; b=GGHkZUBInNS2eawKVqyh2dZiBgqBA0ZAt6XqWzq6FhWyVhlXFPbnrSHWOAFPS8Z9ZR dVibOwR1wemIROQr4YCp1xwVf64z1Rg6WMpiGmIbfEBFWPrx7MmRdjb8gV3/SgBP2ZFz a9equnKu6rHXrtF1/q3vcbOQPyLeVxfwNuL+UDob2YQyCPEw22TnPSzcp86A1o8wmep8 1ovlB+LtfWokYN7bMc5KLPeyi/66y6j4HTX1EvxJshk2q4Z+Mrbh6HeBmZDHYOODRsRw ktVTLWOHs/HMh+a+mLrAgjBio5S/1PCoIAKLdzp+GyxBK5Ra+Tjpp58IHq5VCMfwp/Vd YXZw== 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=d5WGGczUDQ+z5x6mRYmC5MZD9AX2DybKW9Ucl1ZZ5x4=; b=Jo3qOrDW+XT7cBaxgsY0Zkql3Ie95QMTqPpHxg+2P/U4ey9620Z5uIs+cY6bfAh+KQ GhHvOxGkK2KvMaKQfdU0BNOHnnawiYLpDJ2TPYA/OJ0snoB2sr350XN2WuNWCmJW/9U9 AhvpnFnPtddlWCloNgbKz3JTt81tDmAwf+REkvoLVIV0qPpna/M0k57CXR022sngEkoN z80o8o23tUDy/q0B2ebd/soxqHbIgNYduWAXBBp7rd0yLl78LImlSLKO7aSTE5lYKc0B axfb2qyrzXzA+N0mcgfQFNeX5vNOwFQZ2SqcUEz9aZQg0ioYvScUXGKl5q/FxUNWTUb1 vUhw== X-Gm-Message-State: AOAM532U2dBskQqnXVilGx0vN8gTMzesfSqrTVr2Z7PpPj8cto1lOams A/OdIe+pjo6OkIWHX/A2yqIhmQ== X-Google-Smtp-Source: ABdhPJxWCOn5XF/Z6Scsndh/Ax3SBXXxu2JEXA+6Z/V9aXahHy5B6KiYzK39pJgPk6HYOKcI6cp8rA== X-Received: by 2002:a5d:6589:: with SMTP id q9mr2297646wru.284.1626780985461; Tue, 20 Jul 2021 04:36:25 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:83e0:11ac:c870:2b97]) by smtp.gmail.com with ESMTPSA id d9sm23135294wrx.76.2021.07.20.04.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 04:36:25 -0700 (PDT) Date: Tue, 20 Jul 2021 12:36:21 +0100 From: Quentin Perret To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, dbrazdil@google.com, Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: Re: [PATCH 03/16] KVM: arm64: Turn kvm_pgtable_stage2_set_owner into kvm_pgtable_stage2_annotate Message-ID: References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-4-maz@kernel.org> <871r7t9tgi.wl-maz@kernel.org> <87zguh8c4l.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zguh8c4l.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 20 Jul 2021 at 12:20:58 (+0100), Marc Zyngier wrote: > On Tue, 20 Jul 2021 11:38:17 +0100, > Quentin Perret wrote: > > > > On Tuesday 20 Jul 2021 at 11:21:17 (+0100), Marc Zyngier wrote: > > > On Tue, 20 Jul 2021 11:09:21 +0100, > > > Quentin Perret wrote: > > > > > > > > On Thursday 15 Jul 2021 at 17:31:46 (+0100), Marc Zyngier wrote: > > > > > @@ -815,7 +807,7 @@ int kvm_pgtable_stage2_set_owner(struct kvm_pgtable *pgt, u64 addr, u64 size, > > > > > .arg = &map_data, > > > > > }; > > > > > > > > > > - if (owner_id > KVM_MAX_OWNER_ID) > > > > > + if (!annotation || (annotation & PTE_VALID)) > > > > > return -EINVAL; > > > > > > > > Why do you consider annotation==0 invalid? The assumption so far has > > > > been that the owner_id for the host is 0, so annotating a range with 0s > > > > should be a valid operation -- this will be required when e.g. > > > > transferring ownership of a page back to the host. > > > > > > How do you then distinguish it from an empty entry that doesn't map to > > > anything at all? > > > > You don't, but that's beauty of it :) > > > > The host starts with a PGD full of zeroes, which in terms of ownership > > means that it owns the entire (I)PA space. And it loses ownership of a > > page only when we explicitly annotate it with an owner id != 0. > > Right. But this scheme doesn't apply to the guests, does it? Right, the meaning of a NULL PTE in guests will clearly be something different, but I guess the interpretation of what invalid mappings mean is up to the caller. > Don't we > need something that is non-null to preserve the table refcounting? Sure, but do we care? If the table entry gets zeroed we're then basically using an 'invalid block' mapping to annotate the entire block range with '0', whatever that means. For guests it won't mean much, but for the host that would mean sole ownership of the entire range. 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=-6.1 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,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 96F0AC07E9B for ; Tue, 20 Jul 2021 11:36:30 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 09B5C6113A for ; Tue, 20 Jul 2021 11:36:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09B5C6113A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 73B3B4B0BF; Tue, 20 Jul 2021 07:36:29 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Rn-VCrs2NEVJ; Tue, 20 Jul 2021 07:36:28 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4AB454B0CC; Tue, 20 Jul 2021 07:36:28 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8F07D4B0C0 for ; Tue, 20 Jul 2021 07:36:27 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZRIJwBNCXyBn for ; Tue, 20 Jul 2021 07:36:26 -0400 (EDT) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 812914B0BF for ; Tue, 20 Jul 2021 07:36:26 -0400 (EDT) Received: by mail-wr1-f47.google.com with SMTP id m2so25665857wrq.2 for ; Tue, 20 Jul 2021 04:36:26 -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=d5WGGczUDQ+z5x6mRYmC5MZD9AX2DybKW9Ucl1ZZ5x4=; b=GGHkZUBInNS2eawKVqyh2dZiBgqBA0ZAt6XqWzq6FhWyVhlXFPbnrSHWOAFPS8Z9ZR dVibOwR1wemIROQr4YCp1xwVf64z1Rg6WMpiGmIbfEBFWPrx7MmRdjb8gV3/SgBP2ZFz a9equnKu6rHXrtF1/q3vcbOQPyLeVxfwNuL+UDob2YQyCPEw22TnPSzcp86A1o8wmep8 1ovlB+LtfWokYN7bMc5KLPeyi/66y6j4HTX1EvxJshk2q4Z+Mrbh6HeBmZDHYOODRsRw ktVTLWOHs/HMh+a+mLrAgjBio5S/1PCoIAKLdzp+GyxBK5Ra+Tjpp58IHq5VCMfwp/Vd YXZw== 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=d5WGGczUDQ+z5x6mRYmC5MZD9AX2DybKW9Ucl1ZZ5x4=; b=CRFUz8Yk5+5rRDiVC0b6A1mFY/7iimRcdvqMNQPORQ6Ye+0iyISlNaXDz3qFUX3lQf WwIhMW/MGFgwmONdYRDCae64iDxasQwcz7vzqpT6Ea3lEvLKzejsQwAY8EhrSF0DnyBR XH1Sp0z+c5tcfaUUUU9ZRR12tP9+PEWMmwBxggnvrDbN/Cxk+se42XBtJqczaTb2AlwJ 4NGoj2d7XXq00m5HsR+t7f72oKievaVeMmNq+4GCuDGf58+R7vqpSugPJY2kZIdH5/a5 6Ga/BqzfqFPH5u0Lc141HYyP9p/bUF2jIK/3thPziKLtxiJ7gk8Q4Zv+pMr6VvpT/OHv aQJw== X-Gm-Message-State: AOAM530AcKnSJ4P1Mvxb0FtFLndXxoVlIYBfiDfffATCM6ffTMn/3KsS EFlTXACBLiDNP1PIcV2uJa7o2A== X-Google-Smtp-Source: ABdhPJxWCOn5XF/Z6Scsndh/Ax3SBXXxu2JEXA+6Z/V9aXahHy5B6KiYzK39pJgPk6HYOKcI6cp8rA== X-Received: by 2002:a5d:6589:: with SMTP id q9mr2297646wru.284.1626780985461; Tue, 20 Jul 2021 04:36:25 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:83e0:11ac:c870:2b97]) by smtp.gmail.com with ESMTPSA id d9sm23135294wrx.76.2021.07.20.04.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 04:36:25 -0700 (PDT) Date: Tue, 20 Jul 2021 12:36:21 +0100 From: Quentin Perret To: Marc Zyngier Subject: Re: [PATCH 03/16] KVM: arm64: Turn kvm_pgtable_stage2_set_owner into kvm_pgtable_stage2_annotate Message-ID: References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-4-maz@kernel.org> <871r7t9tgi.wl-maz@kernel.org> <87zguh8c4l.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87zguh8c4l.wl-maz@kernel.org> Cc: kernel-team@android.com, kvm@vger.kernel.org, Srivatsa Vaddagiri , linux-kernel@vger.kernel.org, Shanker R Donthineni , will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Tuesday 20 Jul 2021 at 12:20:58 (+0100), Marc Zyngier wrote: > On Tue, 20 Jul 2021 11:38:17 +0100, > Quentin Perret wrote: > > > > On Tuesday 20 Jul 2021 at 11:21:17 (+0100), Marc Zyngier wrote: > > > On Tue, 20 Jul 2021 11:09:21 +0100, > > > Quentin Perret wrote: > > > > > > > > On Thursday 15 Jul 2021 at 17:31:46 (+0100), Marc Zyngier wrote: > > > > > @@ -815,7 +807,7 @@ int kvm_pgtable_stage2_set_owner(struct kvm_pgtable *pgt, u64 addr, u64 size, > > > > > .arg = &map_data, > > > > > }; > > > > > > > > > > - if (owner_id > KVM_MAX_OWNER_ID) > > > > > + if (!annotation || (annotation & PTE_VALID)) > > > > > return -EINVAL; > > > > > > > > Why do you consider annotation==0 invalid? The assumption so far has > > > > been that the owner_id for the host is 0, so annotating a range with 0s > > > > should be a valid operation -- this will be required when e.g. > > > > transferring ownership of a page back to the host. > > > > > > How do you then distinguish it from an empty entry that doesn't map to > > > anything at all? > > > > You don't, but that's beauty of it :) > > > > The host starts with a PGD full of zeroes, which in terms of ownership > > means that it owns the entire (I)PA space. And it loses ownership of a > > page only when we explicitly annotate it with an owner id != 0. > > Right. But this scheme doesn't apply to the guests, does it? Right, the meaning of a NULL PTE in guests will clearly be something different, but I guess the interpretation of what invalid mappings mean is up to the caller. > Don't we > need something that is non-null to preserve the table refcounting? Sure, but do we care? If the table entry gets zeroed we're then basically using an 'invalid block' mapping to annotate the entire block range with '0', whatever that means. For guests it won't mean much, but for the host that would mean sole ownership of the entire range. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-7.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 E5818C07E9B for ; Tue, 20 Jul 2021 11:38:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B4D6D61029 for ; Tue, 20 Jul 2021 11:38:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4D6D61029 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=kma2qGm08SJotnnPfhAbngwZfRK7TZTlEQe/YRErgss=; b=0RUHJd0htequ0p dmtap3H04zI9nE/+9QOvSwMy04EGVs39KD6euGtEj+SnrXtbZYH9bzACzUmT8Dzus6B+4HrcYVCET /gC3gXCFZEcBYtD9gozZNl4cE7SfLSCXMEkolOzVm0q3g8zaesEV+ikc4JH1sTGm5zgMzP/yklb5x H99RDmNDxvPs9+ucijfII/pEIAePwUu5EoVKPrASyT3h2/XUKAOMT2TLM9pFh4eL5jC9CdbWs1McL ffK5tFE3pgCKlGaxJiB9JNXjy0E7UDb6BSKLhp9HN49LcydRtiIBNWVeWnsRUwxLZ0Jw0oQj0n3cK MWbkmUvCwd27OH5MDl1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5o34-00Cfou-Vd; Tue, 20 Jul 2021 11:36:31 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5o31-00CfoM-Ai for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 11:36:28 +0000 Received: by mail-wr1-x436.google.com with SMTP id r11so25611338wro.9 for ; Tue, 20 Jul 2021 04:36:26 -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=d5WGGczUDQ+z5x6mRYmC5MZD9AX2DybKW9Ucl1ZZ5x4=; b=GGHkZUBInNS2eawKVqyh2dZiBgqBA0ZAt6XqWzq6FhWyVhlXFPbnrSHWOAFPS8Z9ZR dVibOwR1wemIROQr4YCp1xwVf64z1Rg6WMpiGmIbfEBFWPrx7MmRdjb8gV3/SgBP2ZFz a9equnKu6rHXrtF1/q3vcbOQPyLeVxfwNuL+UDob2YQyCPEw22TnPSzcp86A1o8wmep8 1ovlB+LtfWokYN7bMc5KLPeyi/66y6j4HTX1EvxJshk2q4Z+Mrbh6HeBmZDHYOODRsRw ktVTLWOHs/HMh+a+mLrAgjBio5S/1PCoIAKLdzp+GyxBK5Ra+Tjpp58IHq5VCMfwp/Vd YXZw== 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=d5WGGczUDQ+z5x6mRYmC5MZD9AX2DybKW9Ucl1ZZ5x4=; b=RrPI+ifQQ3iOC1UoIKTWj2bBZ9qFvDkPb7EhJH8CiUuFauljdG+l1w3eUjxM9m3cxb yjUrm+D4ByrQh7Z3XGs6xhQ87bCCju4JMIA6E7QUFcVdndIRctaIKhkwZkDhVSlrwdpc wFW74e61qoW2pbPyVIQt7OfWeDhV3RE2/K7EmKnbdVQ85HK+XG4K3eTzl+yNlAQxf3qT iPoPojtpxX0kdZoGjTcjYbtw4YVo5qoLG+LVju6KuE5VTkS3jQrkKxTGvRsDUTvHLOeH s4BaIxwH0RS9WmcFe3rd8ag//7J+GTOdOqbD26qQ4iWJsVyDVwp+qHdpBLZUJ5gq8d/j lCOg== X-Gm-Message-State: AOAM532STqeNt1tbdQ1JjWH4+pqdekz26UKgAnxGrd7mfNKZsbWAokzX /G2G831m+26FCZU3AlyOetSPRA== X-Google-Smtp-Source: ABdhPJxWCOn5XF/Z6Scsndh/Ax3SBXXxu2JEXA+6Z/V9aXahHy5B6KiYzK39pJgPk6HYOKcI6cp8rA== X-Received: by 2002:a5d:6589:: with SMTP id q9mr2297646wru.284.1626780985461; Tue, 20 Jul 2021 04:36:25 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:83e0:11ac:c870:2b97]) by smtp.gmail.com with ESMTPSA id d9sm23135294wrx.76.2021.07.20.04.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 04:36:25 -0700 (PDT) Date: Tue, 20 Jul 2021 12:36:21 +0100 From: Quentin Perret To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, dbrazdil@google.com, Srivatsa Vaddagiri , Shanker R Donthineni , James Morse , Suzuki K Poulose , Alexandru Elisei , kernel-team@android.com Subject: Re: [PATCH 03/16] KVM: arm64: Turn kvm_pgtable_stage2_set_owner into kvm_pgtable_stage2_annotate Message-ID: References: <20210715163159.1480168-1-maz@kernel.org> <20210715163159.1480168-4-maz@kernel.org> <871r7t9tgi.wl-maz@kernel.org> <87zguh8c4l.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87zguh8c4l.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_043627_434876_C316CD65 X-CRM114-Status: GOOD ( 25.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Tuesday 20 Jul 2021 at 12:20:58 (+0100), Marc Zyngier wrote: > On Tue, 20 Jul 2021 11:38:17 +0100, > Quentin Perret wrote: > > > > On Tuesday 20 Jul 2021 at 11:21:17 (+0100), Marc Zyngier wrote: > > > On Tue, 20 Jul 2021 11:09:21 +0100, > > > Quentin Perret wrote: > > > > > > > > On Thursday 15 Jul 2021 at 17:31:46 (+0100), Marc Zyngier wrote: > > > > > @@ -815,7 +807,7 @@ int kvm_pgtable_stage2_set_owner(struct kvm_pgtable *pgt, u64 addr, u64 size, > > > > > .arg = &map_data, > > > > > }; > > > > > > > > > > - if (owner_id > KVM_MAX_OWNER_ID) > > > > > + if (!annotation || (annotation & PTE_VALID)) > > > > > return -EINVAL; > > > > > > > > Why do you consider annotation==0 invalid? The assumption so far has > > > > been that the owner_id for the host is 0, so annotating a range with 0s > > > > should be a valid operation -- this will be required when e.g. > > > > transferring ownership of a page back to the host. > > > > > > How do you then distinguish it from an empty entry that doesn't map to > > > anything at all? > > > > You don't, but that's beauty of it :) > > > > The host starts with a PGD full of zeroes, which in terms of ownership > > means that it owns the entire (I)PA space. And it loses ownership of a > > page only when we explicitly annotate it with an owner id != 0. > > Right. But this scheme doesn't apply to the guests, does it? Right, the meaning of a NULL PTE in guests will clearly be something different, but I guess the interpretation of what invalid mappings mean is up to the caller. > Don't we > need something that is non-null to preserve the table refcounting? Sure, but do we care? If the table entry gets zeroed we're then basically using an 'invalid block' mapping to annotate the entire block range with '0', whatever that means. For guests it won't mean much, but for the host that would mean sole ownership of the entire range. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel