From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Date: Mon, 14 Aug 2023 14:54:32 -0700 Subject: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes In-Reply-To: <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-9-seanjc@google.com> <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, Aug 14, 2023, Binbin Wu wrote: > > On 7/19/2023 7:44 AM, Sean Christopherson wrote: > > + struct kvm_mmu_notifier_range post_set_range = { > > + .start = start, > > + .end = end, > > + .arg.attributes = attributes, > > + .handler = kvm_arch_post_set_memory_attributes, > > + .on_lock = (void *)kvm_null_fn, > > + .on_unlock = kvm_mmu_invalidate_end, > > + .may_block = true, > > + }; > > + unsigned long i; > > + void *entry; > > + int r; > > + > > + entry = attributes ? xa_mk_value(attributes) : NULL; > Why attributes of value 0 is considered not a value? Is it because 0 is not > a valid value when RWX is considered in the future? 0 values don't require an entry in the xarray, i.e. don't need to be stored and so don't consume memory. The potential conflict with a RWX=0 entry has already been noted, but we'll cross that bridge when we get to it, e.g. KVM can easily support RWX=0 by using an internal "valid" flag. > Both the changelog and the document added mention that the address and size > of attrs will be updated to > "reflect the actual pages of the memory range have been successfully set to > the attributes", but it doesn't. Yeah, on the todo list, all of the changelogs are horribly stale. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10256DF51 for ; Mon, 14 Aug 2023 21:54:34 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-55c964d031aso8936769a12.1 for ; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=WyQ6Tn/5h37xMsEIDmbWcY+nQiTqqFoftlXVBTiztMb2A7vinkou0FyJxT5Tj+pa31 3y4mktmY47itqZcGsKCOeUubQi9MQwPyYS/ntrx9oV/jIdUAoZkwRuGY0yw403B+hUV5 PyUzYrySs29/O30p+yDsELGRzby+1aqFcxoBBJ6omQFPygNitIVTJAp2Hnd4R0/QcY2H EgizfgVBfhm/BlB4owWFjSnqlPuhKRjVS+MvDjPpwOsN8USa7haRJjhrCn+/9m5M/b9b HnVauoeuLnwYhNy2SBnjlv/xkJdMMlVKqHESswng1uUarqPNC4oB5B1VogZQC9cpA3Kv gLzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=CURi/WGYBSwYN1mptTCgb6IC381/anDr2CBP5uHdo+LyP9ir2gsvLvhAT/FEyIurk4 JR/eTC7Ah7jYSq2XenPSsh6tHlN9D8vUnlA3pay9W4tcU386LVe1YiWauSl+EiicYFxs XPnmvWDjswKpCG4jtKVUwXJ1rvr+756pCWV9D3hChrg4ZIfxYok5v5Kcz7Lwd+btirdE znTD7Y8fff+YOObUdOO/vtuPJ/iXSBtUDUCgGnQTF/0A61rmuR/VgnoLoR0CsoU6TtaF U1aIq9awOCE7jVn5YqMA4l2YaRKXHnAYKV6rMg6oq5Tzoh6E3JsYsOAqMKcUoxBMQcrL /0eA== X-Gm-Message-State: AOJu0Yw6FR0rvG5CuPyZequDSqTOwW5K4ClV+LF8nIvXU8kKpBMLDjwR 9m+phnEk/L/paHo5CMadYNCefnyGiww= X-Google-Smtp-Source: AGHT+IGPzyG2ye2a1feyqcG86dyCHC82qzx5i2/p6ALHRmr0rfFoFMM8MlFz9jxGz9wjwtqC3ppaRbddXVE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:9f12:0:b0:565:3355:87b0 with SMTP id g18-20020a639f12000000b00565335587b0mr2044577pge.5.1692050074189; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) Date: Mon, 14 Aug 2023 14:54:32 -0700 In-Reply-To: <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-9-seanjc@google.com> <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Message-ID: Subject: Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes From: Sean Christopherson To: Binbin Wu Cc: Chao Peng , Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" Content-Type: text/plain; charset="us-ascii" On Mon, Aug 14, 2023, Binbin Wu wrote: > > On 7/19/2023 7:44 AM, Sean Christopherson wrote: > > + struct kvm_mmu_notifier_range post_set_range = { > > + .start = start, > > + .end = end, > > + .arg.attributes = attributes, > > + .handler = kvm_arch_post_set_memory_attributes, > > + .on_lock = (void *)kvm_null_fn, > > + .on_unlock = kvm_mmu_invalidate_end, > > + .may_block = true, > > + }; > > + unsigned long i; > > + void *entry; > > + int r; > > + > > + entry = attributes ? xa_mk_value(attributes) : NULL; > Why attributes of value 0 is considered not a value? Is it because 0 is not > a valid value when RWX is considered in the future? 0 values don't require an entry in the xarray, i.e. don't need to be stored and so don't consume memory. The potential conflict with a RWX=0 entry has already been noted, but we'll cross that bridge when we get to it, e.g. KVM can easily support RWX=0 by using an internal "valid" flag. > Both the changelog and the document added mention that the address and size > of attrs will be updated to > "reflect the actual pages of the memory range have been successfully set to > the attributes", but it doesn't. Yeah, on the todo list, all of the changelogs are horribly stale. 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F2841C04A6A for ; Mon, 14 Aug 2023 21:54:46 +0000 (UTC) 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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/0/6E2R+BgnzShHIVRHP8AbQSceBn2lnDszijknnwys=; b=MOZqG7C9+kDb8HjEpFuUAJRLnL GWQgH33pqTUyQPXpLsDBuphovasItnZJS3gp4yOPgLKa1Mt7xDIZm3QbgNpqpKLvEVSzgkvEhBbJT SpiDMOoeEKIN+tH1bZUSayXR2lNth4QY+38485Z7w07gq+0C2yShcJ5j0ux8ORV2N1J2w6Ert6aZy akkaGzvm9b05soPbonvEAjT2W1ZXNETCSPwVxOJF2g7KK81+xv9xFwu0CF0YWbW3HRB+O6HNhvQeO BVdPaNVWOU5SPcZf+84C8bmqCRSXNOcTuiBwZZTwwrPLY3l/PfOBUlOOcfYxpOVZlll4CSHc4qqDa XAXY2kMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVfWI-000PuO-1r; Mon, 14 Aug 2023 21:54:38 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVfWF-000PtF-35 for linux-riscv@lists.infradead.org; Mon, 14 Aug 2023 21:54:37 +0000 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-55bf2bf1cdeso8921523a12.3 for ; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=WyQ6Tn/5h37xMsEIDmbWcY+nQiTqqFoftlXVBTiztMb2A7vinkou0FyJxT5Tj+pa31 3y4mktmY47itqZcGsKCOeUubQi9MQwPyYS/ntrx9oV/jIdUAoZkwRuGY0yw403B+hUV5 PyUzYrySs29/O30p+yDsELGRzby+1aqFcxoBBJ6omQFPygNitIVTJAp2Hnd4R0/QcY2H EgizfgVBfhm/BlB4owWFjSnqlPuhKRjVS+MvDjPpwOsN8USa7haRJjhrCn+/9m5M/b9b HnVauoeuLnwYhNy2SBnjlv/xkJdMMlVKqHESswng1uUarqPNC4oB5B1VogZQC9cpA3Kv gLzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=ayN9YuRRGdROxdu81chyt3ZxXUOJki4kWaC2+0AI+gVO9RX4Pv2DTO2oqrJpqprh5Y 4gvWstEAlMh1DQ7WGVWSbGcjYVi9kHnheRXoszGecf3WicH59vjuPnI00lM0O77ntUE6 E122/CgnBFeA4gqQykhDMbNM3bQx7rqbAQO1cV1JvZESl1iis5mSWTzC8rGtOEJCNbL1 Q43cRnpBpuLrEIPfB/oAvA8/L4J73y6ToiRtwChoNdRMpn3pM+Hn7MDNA1jZlu/h5cN/ zJDJoodNkIunTMiFFofOAxNK0LPqM20GLfG8b8oyiSI/F06yHE51UiBzoBOB/5u/p+8Z w4fQ== X-Gm-Message-State: AOJu0YyP0Q9xn8gjhwWJWFlCfgffdG/0TfB5qXqFgp1l/+AcVpK0/TNJ u4zln5skztcPUzdMBhkknYKy8Hzm7eM= X-Google-Smtp-Source: AGHT+IGPzyG2ye2a1feyqcG86dyCHC82qzx5i2/p6ALHRmr0rfFoFMM8MlFz9jxGz9wjwtqC3ppaRbddXVE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:9f12:0:b0:565:3355:87b0 with SMTP id g18-20020a639f12000000b00565335587b0mr2044577pge.5.1692050074189; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) Date: Mon, 14 Aug 2023 14:54:32 -0700 In-Reply-To: <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-9-seanjc@google.com> <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Message-ID: Subject: Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes From: Sean Christopherson To: Binbin Wu Cc: Chao Peng , Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230814_145436_017537_ECCCC8EB X-CRM114-Status: GOOD ( 15.29 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, Aug 14, 2023, Binbin Wu wrote: > > On 7/19/2023 7:44 AM, Sean Christopherson wrote: > > + struct kvm_mmu_notifier_range post_set_range = { > > + .start = start, > > + .end = end, > > + .arg.attributes = attributes, > > + .handler = kvm_arch_post_set_memory_attributes, > > + .on_lock = (void *)kvm_null_fn, > > + .on_unlock = kvm_mmu_invalidate_end, > > + .may_block = true, > > + }; > > + unsigned long i; > > + void *entry; > > + int r; > > + > > + entry = attributes ? xa_mk_value(attributes) : NULL; > Why attributes of value 0 is considered not a value? Is it because 0 is not > a valid value when RWX is considered in the future? 0 values don't require an entry in the xarray, i.e. don't need to be stored and so don't consume memory. The potential conflict with a RWX=0 entry has already been noted, but we'll cross that bridge when we get to it, e.g. KVM can easily support RWX=0 by using an internal "valid" flag. > Both the changelog and the document added mention that the address and size > of attrs will be updated to > "reflect the actual pages of the memory range have been successfully set to > the attributes", but it doesn't. Yeah, on the todo list, all of the changelogs are horribly stale. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5579C04A6A for ; Mon, 14 Aug 2023 21:55:35 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=WyQ6Tn/5; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RPp9f0npyz3cRk for ; Tue, 15 Aug 2023 07:55:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20221208 header.b=WyQ6Tn/5; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--seanjc.bounces.google.com (client-ip=2607:f8b0:4864:20::54a; helo=mail-pg1-x54a.google.com; envelope-from=3mqlazaykdhcnzviexbjjbgz.xjhgdipskkx-yzqgdnon.jugvwn.jmb@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RPp8d0gJNz30fF for ; Tue, 15 Aug 2023 07:54:39 +1000 (AEST) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-55c964d031aso8936777a12.1 for ; Mon, 14 Aug 2023 14:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=WyQ6Tn/5h37xMsEIDmbWcY+nQiTqqFoftlXVBTiztMb2A7vinkou0FyJxT5Tj+pa31 3y4mktmY47itqZcGsKCOeUubQi9MQwPyYS/ntrx9oV/jIdUAoZkwRuGY0yw403B+hUV5 PyUzYrySs29/O30p+yDsELGRzby+1aqFcxoBBJ6omQFPygNitIVTJAp2Hnd4R0/QcY2H EgizfgVBfhm/BlB4owWFjSnqlPuhKRjVS+MvDjPpwOsN8USa7haRJjhrCn+/9m5M/b9b HnVauoeuLnwYhNy2SBnjlv/xkJdMMlVKqHESswng1uUarqPNC4oB5B1VogZQC9cpA3Kv gLzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=U86T9Bnc09KCMSyc4eGh90ZZQo19qJ+5zoHYHL882suLK2YwjJ1MfM4lFP5KoLm5Gi jFrIrJcx5/i/9q6me8v3x41QyvoeZh0q7RRIYDCuka/GGD1YpWX0CgoktRPG0xOXZl/9 PNqjI7P4uvcEcGAi0vjuTjkRenwI+1kytCVvWlblgpV+NXjg5xls19vlJFMWgI2I4Dbk eDVdOlMKWJDysRYR680ADRlqnpJS1ra8+ZR8rZBvRo3lJ8sAgt3TqqDJ0YDcaZuwpNfo 22uq3x8ey3KZq8W3VFLNtVLm34DP/Hp2isSUcCJiv7y8JGCJTCb1AI4dn/IvFqXhrPqS AJGg== X-Gm-Message-State: AOJu0YyeHsTlsiUALgl1wdCKWAkHzT0Ye4PxnV73ROgQ02TjJUv/qtU4 jAeSRlYBd/g9RUvfz+fKhxJNFu41YJg= X-Google-Smtp-Source: AGHT+IGPzyG2ye2a1feyqcG86dyCHC82qzx5i2/p6ALHRmr0rfFoFMM8MlFz9jxGz9wjwtqC3ppaRbddXVE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:9f12:0:b0:565:3355:87b0 with SMTP id g18-20020a639f12000000b00565335587b0mr2044577pge.5.1692050074189; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) Date: Mon, 14 Aug 2023 14:54:32 -0700 In-Reply-To: <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-9-seanjc@google.com> <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Message-ID: Subject: Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes From: Sean Christopherson To: Binbin Wu Content-Type: text/plain; charset="us-ascii" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, David Hildenbrand , Yu Zhang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chao Peng , linux-riscv@lists.infradead.org, Isaku Yamahata , Paul Moore , Marc Zyngier , Huacai Chen , James Morris , "Matthew Wilcox \(Oracle\)" , Wang , Fuad Tabba , Jarkko Sakkinen , "Serge E. Hallyn" , Maciej Szmigiero , Albert Ou , Vlastimil Babka , Michael Roth , Ackerley Tng , Paul Walmsley , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Quentin Perret , Liam Merwick , linux-mips@vger.kernel.org, Oliver Upton , linux-security-module@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Anup Patel , linux-fsdevel@vger.kernel.org, Paolo Bonzini , Andrew Morton , Vishal Annapurve , linuxppc-dev@lists.ozlabs.org, "Kirill A . Shutemov" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Aug 14, 2023, Binbin Wu wrote: > > On 7/19/2023 7:44 AM, Sean Christopherson wrote: > > + struct kvm_mmu_notifier_range post_set_range = { > > + .start = start, > > + .end = end, > > + .arg.attributes = attributes, > > + .handler = kvm_arch_post_set_memory_attributes, > > + .on_lock = (void *)kvm_null_fn, > > + .on_unlock = kvm_mmu_invalidate_end, > > + .may_block = true, > > + }; > > + unsigned long i; > > + void *entry; > > + int r; > > + > > + entry = attributes ? xa_mk_value(attributes) : NULL; > Why attributes of value 0 is considered not a value? Is it because 0 is not > a valid value when RWX is considered in the future? 0 values don't require an entry in the xarray, i.e. don't need to be stored and so don't consume memory. The potential conflict with a RWX=0 entry has already been noted, but we'll cross that bridge when we get to it, e.g. KVM can easily support RWX=0 by using an internal "valid" flag. > Both the changelog and the document added mention that the address and size > of attrs will be updated to > "reflect the actual pages of the memory range have been successfully set to > the attributes", but it doesn't. Yeah, on the todo list, all of the changelogs are horribly stale. 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 73E86C04A6A for ; Mon, 14 Aug 2023 21:55:08 +0000 (UTC) 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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1MP7+U7L858JRaWZ1WJ9ykVwCLwYFojGPErLiIGEBzA=; b=3EVTAU7cMVnMjn7ShUukYMFEm7 eQ4U9+U7+gAttJw7Uz7wQu2TwHjkPsJ4Kkbw8zph88R35F9bqBq8sEq8Hb5hKGg1on/Rtvax3pDLI 4hWSI5wlZEc+2yEK4H/RI5vvCayNIUHLQ53asOeHo/jMELhNP1XL9XWxLeuUB+9RHEy+Upo4gEng0 gYTGXqs4ftkk1PtuM/hHV5SxuuyBgMUJy61Nb4E+7MXdgdK1UkFCDySpj35w7pQGE+Swx0d2J64zQ Mp/Y6SbcFP2wgMTILF2BIEbvkdhOHJkXT1I04Z9+1IMGOkbgZlFHj2c9HcfrxIkyVvB7bW341uatn gSyieI1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVfWJ-000Pv0-0u; Mon, 14 Aug 2023 21:54:39 +0000 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVfWG-000PtE-1J for linux-arm-kernel@lists.infradead.org; Mon, 14 Aug 2023 21:54:37 +0000 Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-55bf2bf1cdeso8921521a12.3 for ; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=WyQ6Tn/5h37xMsEIDmbWcY+nQiTqqFoftlXVBTiztMb2A7vinkou0FyJxT5Tj+pa31 3y4mktmY47itqZcGsKCOeUubQi9MQwPyYS/ntrx9oV/jIdUAoZkwRuGY0yw403B+hUV5 PyUzYrySs29/O30p+yDsELGRzby+1aqFcxoBBJ6omQFPygNitIVTJAp2Hnd4R0/QcY2H EgizfgVBfhm/BlB4owWFjSnqlPuhKRjVS+MvDjPpwOsN8USa7haRJjhrCn+/9m5M/b9b HnVauoeuLnwYhNy2SBnjlv/xkJdMMlVKqHESswng1uUarqPNC4oB5B1VogZQC9cpA3Kv gLzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692050074; x=1692654874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WLV8cwl+q0+MgeCaKnjEbSXBm+ijn/cuT9eg2QvMQy8=; b=W94hizJMp766NqyIYeXKu9xKZ2GRf9CAwFgHEaPUD7PiTLslBCx5udxLD6RNwTsBVL EsYI6Qdag5vivgsFbAIFe905txXYDn3/x57zZq+rMq1PumXu+wM3Xdvt6kPl4Lq2V1YB +94qeR7SrqlxVkTBIERohYU00+PpVkN/zehqxkUn2I4EITaHrsx/3mO+31BKotf/ztvj MGdyE66op4w85k5eJSsIQUyNEY19tB28fVbx19ikpBAzM99FHSli3FQUChFTDZJVWV5X Mgr22tbczJtryGTHrEuuERCLGO+F+iB2JTOs6T94Uq6IvyOWZBeKFO4FzmdZg9rQKLEU cr6w== X-Gm-Message-State: AOJu0YyOYrstRu7eBrN9M7xceFXigwR52NStnq8xAsjODKH/OHDF8Smx 1xcpK8NP8InqT2E9KtfEnN7bHyzOyR8= X-Google-Smtp-Source: AGHT+IGPzyG2ye2a1feyqcG86dyCHC82qzx5i2/p6ALHRmr0rfFoFMM8MlFz9jxGz9wjwtqC3ppaRbddXVE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:9f12:0:b0:565:3355:87b0 with SMTP id g18-20020a639f12000000b00565335587b0mr2044577pge.5.1692050074189; Mon, 14 Aug 2023 14:54:34 -0700 (PDT) Date: Mon, 14 Aug 2023 14:54:32 -0700 In-Reply-To: <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Mime-Version: 1.0 References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-9-seanjc@google.com> <02239d95-0253-a223-28c2-016cca3ab4d2@linux.intel.com> Message-ID: Subject: Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes From: Sean Christopherson To: Binbin Wu Cc: Chao Peng , Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230814_145436_444000_F52EA312 X-CRM114-Status: GOOD ( 16.87 ) 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 Mon, Aug 14, 2023, Binbin Wu wrote: > > On 7/19/2023 7:44 AM, Sean Christopherson wrote: > > + struct kvm_mmu_notifier_range post_set_range = { > > + .start = start, > > + .end = end, > > + .arg.attributes = attributes, > > + .handler = kvm_arch_post_set_memory_attributes, > > + .on_lock = (void *)kvm_null_fn, > > + .on_unlock = kvm_mmu_invalidate_end, > > + .may_block = true, > > + }; > > + unsigned long i; > > + void *entry; > > + int r; > > + > > + entry = attributes ? xa_mk_value(attributes) : NULL; > Why attributes of value 0 is considered not a value? Is it because 0 is not > a valid value when RWX is considered in the future? 0 values don't require an entry in the xarray, i.e. don't need to be stored and so don't consume memory. The potential conflict with a RWX=0 entry has already been noted, but we'll cross that bridge when we get to it, e.g. KVM can easily support RWX=0 by using an internal "valid" flag. > Both the changelog and the document added mention that the address and size > of attrs will be updated to > "reflect the actual pages of the memory range have been successfully set to > the attributes", but it doesn't. Yeah, on the todo list, all of the changelogs are horribly stale. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel