[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87o7t475o7.fsf@linaro.org>
Date: Fri, 18 Nov 2022 13:23:51 +0000
From: Alex Bennée <alex.bennee@...aro.org>
To: Chao Peng <chao.p.peng@...ux.intel.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
linux-arch@...r.kernel.org, linux-api@...r.kernel.org,
linux-doc@...r.kernel.org, qemu-devel@...gnu.org,
Paolo Bonzini <pbonzini@...hat.com>,
Jonathan Corbet <corbet@....net>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H . Peter Anvin" <hpa@...or.com>,
Hugh Dickins <hughd@...gle.com>,
Jeff Layton <jlayton@...nel.org>,
"J . Bruce Fields" <bfields@...ldses.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Shuah Khan <shuah@...nel.org>, Mike Rapoport <rppt@...nel.org>,
Steven Price <steven.price@....com>,
"Maciej S . Szmigiero" <mail@...iej.szmigiero.name>,
Vlastimil Babka <vbabka@...e.cz>,
Vishal Annapurve <vannapurve@...gle.com>,
Yu Zhang <yu.c.zhang@...ux.intel.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
luto@...nel.org, jun.nakajima@...el.com, dave.hansen@...el.com,
ak@...ux.intel.com, david@...hat.com, aarcange@...hat.com,
ddutile@...hat.com, dhildenb@...hat.com,
Quentin Perret <qperret@...gle.com>, tabba@...gle.com,
Michael Roth <michael.roth@....com>, mhocko@...e.com,
Muchun Song <songmuchun@...edance.com>, wei.w.wang@...el.com
Subject: Re: [PATCH v9 3/8] KVM: Add KVM_EXIT_MEMORY_FAULT exit
Chao Peng <chao.p.peng@...ux.intel.com> writes:
> On Thu, Nov 17, 2022 at 03:08:17PM +0000, Alex Bennée wrote:
>>
<snip>
>> >> >> > +
>> >> >> > + /* KVM_EXIT_MEMORY_FAULT */
>> >> >> > + struct {
>> >> >> > + #define KVM_MEMORY_EXIT_FLAG_PRIVATE (1 << 0)
>> >> >> > + __u32 flags;
>> >> >> > + __u32 padding;
>> >> >> > + __u64 gpa;
>> >> >> > + __u64 size;
>> >> >> > + } memory;
>> >> >> > +
>> >> >> > +If exit reason is KVM_EXIT_MEMORY_FAULT then it indicates that the VCPU has
>> >> >> > +encountered a memory error which is not handled by KVM kernel module and
>> >> >> > +userspace may choose to handle it. The 'flags' field indicates the memory
>> >> >> > +properties of the exit.
>> >> >> > +
>> >> >> > + - KVM_MEMORY_EXIT_FLAG_PRIVATE - indicates the memory error is caused by
>> >> >> > + private memory access when the bit is set. Otherwise the memory error is
>> >> >> > + caused by shared memory access when the bit is clear.
>> >> >>
>> >> >> What does a shared memory access failure entail?
>> >> >
>> >> > In the context of confidential computing usages, guest can issue a
>> >> > shared memory access while the memory is actually private from the host
>> >> > point of view. This exit with bit 0 cleared gives userspace a chance to
>> >> > convert the private memory to shared memory on host.
>> >>
>> >> I think this should be explicit rather than implied by the absence of
>> >> another flag. Sean suggested you might want flags for RWX failures so
>> >> maybe something like:
>> >>
>> >> KVM_MEMORY_EXIT_SHARED_FLAG_READ (1 << 0)
>> >> KVM_MEMORY_EXIT_SHARED_FLAG_WRITE (1 << 1)
>> >> KVM_MEMORY_EXIT_SHARED_FLAG_EXECUTE (1 << 2)
>> >> KVM_MEMORY_EXIT_FLAG_PRIVATE (1 << 3)
>> >
>> > Yes, but I would not add 'SHARED' to RWX, they are not share memory
>> > specific, private memory can also set them once introduced.
>>
>> OK so how about:
>>
>> KVM_MEMORY_EXIT_FLAG_READ (1 << 0)
>> KVM_MEMORY_EXIT_FLAG_WRITE (1 << 1)
>> KVM_MEMORY_EXIT_FLAG_EXECUTE (1 << 2)
>> KVM_MEMORY_EXIT_FLAG_SHARED (1 << 3)
>> KVM_MEMORY_EXIT_FLAG_PRIVATE (1 << 4)
>
> We don't actually need a new bit, the opposite side of private is
> shared, i.e. flags with KVM_MEMORY_EXIT_FLAG_PRIVATE cleared expresses
> 'shared'.
If that is always true and we never expect a 3rd type of memory that is
fine. But given we are leaving room for expansion having an explicit bit
allows for that as well as making cases of forgetting to set the flags
more obvious.
--
Alex Bennée
Powered by blists - more mailing lists