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 8CB69C433FE for ; Fri, 7 Jan 2022 16:48: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: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=B/hlxHu+FoJS8zZfXgDdpBHek1d/Az8oBs0BIm3wN3k=; b=e5ryfMVbrHHifR 0NHYYOf0Mfmfy73HNFCSi96WIRtKm3+34M+fgJBtIaiwoq00r7lXUi3yBKqdMCwY5DNWMxUQSAiw1 hPgZymxCPINm8us9gs/xcwt0Nub5b+iA5R/Ph16qOAiuBvc3O7byPJOOkyWkv+T12l7aZcQUSFHUO 0JI3hGEJ9/FP+uJCJaW1rANIWeCrDDyCden4LNbfr2qgALxDabKxU47ZposlQltUgGKrPBvhZ1cs0 Ub0pw1ulBAEISynRxthm5RTOOFyXD3H1ayGXxC2CoMj0hGOWEW++xdaewkgetKv6KQcplR6GTgYKW lVUxNfM6+o1tRVdmrHsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5sOP-004g2w-3k; Fri, 07 Jan 2022 16:47:05 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5sOL-004g23-Gl for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 16:47:03 +0000 Received: by mail-pj1-x1034.google.com with SMTP id m13so5652463pji.3 for ; Fri, 07 Jan 2022 08:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4HKnywQuY4VwXKVwYl3w2RNebnD31WyuWWzy9wpaOH0=; b=BvLHGD7cj4995fLzUhgyy1Xt/a0cC76PQB/jGLGJEKa0b6OFwQ+DrOKU3TYZkymmgS BTeAsvkfWAWnUq1WOqL4vGteu6O2Ld4y5+snVVc5+sU0KjMB4RAAFBkX0HWdnx62O14E jXbutV6k0H84XcWhw++JJI5F1Nykk+sTfnUcCqMOLs4SQ/KBXxWdpyS9MdxgF/KY3KDS NI7p9R4ex+SK8+H2DJkfxklNuGpN9luOoCDx6fhzHrgPfyvFEB+F/9bW9SWvCCoRzQkR jsQqJJLcmMM9F3cF1zM9nzl4zZhWBQy2welvXJT1dZZkyc8P8JLHKlmMJs79hca+JweA XDNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4HKnywQuY4VwXKVwYl3w2RNebnD31WyuWWzy9wpaOH0=; b=qfRv8T2Py/faZvpcShAX9pPjHFZ6LkKxdafuTkJ6e2GFfF7ZAJbaLISLJmfSO1eZbw od2bAiew8vBXv2pzYJwJV4QcO9fph8YTPxJtPXRiBAgv6pxx6F+kxDSY2/RfQhisjliS 857lDjD3SnVfVCLmm9s6PJ3KfISs2aT2T47anOMYlZnTVVInFBWgvCVtQasmQkVuKtZ2 6e+UpJU/NSbP63DMs7pMPBfVHYrjheI1UyxGri9fi09royxmw0MkcxIb+iHxE/+QxVi3 RHzY/EKGcSObDL4ldX72kf60cLOASTcAjrbY7Om7REH5dzVpIYbTOZEo9Riv1xGJXr1+ XWhA== X-Gm-Message-State: AOAM530Z0Ihn3lu/lDBQ05bgl64BgZlSIFy3nE49opYLjXcmLlYptrAg 062n/cjzOseTBw58OzwDhg5qUspdnF8dOw== X-Google-Smtp-Source: ABdhPJwaWYhBGl15DwbN2c5wYPK8kkGXVkvmKvrtvOqisVVfVfKIeJNZMfFu1VFmjZmU/W5QC8QKVg== X-Received: by 2002:a17:90b:88e:: with SMTP id bj14mr16748325pjb.183.1641574020470; Fri, 07 Jan 2022 08:47:00 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id d3sm6735893pfv.192.2022.01.07.08.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 08:47:00 -0800 (PST) Date: Fri, 7 Jan 2022 16:46:56 +0000 From: Sean Christopherson To: David Stevens Cc: Marc Zyngier , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Will Deacon , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Chia-I Wu Subject: Re: [PATCH v5 4/4] KVM: mmu: remove over-aggressive warnings Message-ID: References: <20211129034317.2964790-1-stevensd@google.com> <20211129034317.2964790-5-stevensd@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220107_084701_591406_6B6D5697 X-CRM114-Status: GOOD ( 35.62 ) 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 Fri, Jan 07, 2022, Sean Christopherson wrote: > On Fri, Jan 07, 2022, David Stevens wrote: > > > > These are the type of pages which KVM is currently rejecting. Is this > > > > something that KVM can support? > > > > > > I'm not opposed to it. My complaint is that this series is incomplete in that it > > > allows mapping the memory into the guest, but doesn't support accessing the memory > > > from KVM itself. That means for things to work properly, KVM is relying on the > > > guest to use the memory in a limited capacity, e.g. isn't using the memory as > > > general purpose RAM. That's not problematic for your use case, because presumably > > > the memory is used only by the vGPU, but as is KVM can't enforce that behavior in > > > any way. > > > > > > The really gross part is that failures are not strictly punted to userspace; > > > the resulting error varies significantly depending on how the guest "illegally" > > > uses the memory. > > > > > > My first choice would be to get the amdgpu driver "fixed", but that's likely an > > > unreasonable request since it sounds like the non-KVM behavior is working as intended. > > > > > > One thought would be to require userspace to opt-in to mapping this type of memory > > > by introducing a new memslot flag that explicitly states that the memslot cannot > > > be accessed directly by KVM, i.e. can only be mapped into the guest. That way, > > > KVM has an explicit ABI with respect to how it handles this type of memory, even > > > though the semantics of exactly what will happen if userspace/guest violates the > > > ABI are not well-defined. And internally, KVM would also have a clear touchpoint > > > where it deliberately allows mapping such memslots, as opposed to the more implicit > > > behavior of bypassing ensure_pfn_ref(). > > > > Is it well defined when KVM needs to directly access a memslot? > > Not really, there's certainly no established rule. > > > At least for x86, it looks like most of the use cases are related to nested > > virtualization, except for the call in emulator_cmpxchg_emulated. > > The emulator_cmpxchg_emulated() will hopefully go away in the nearish future[*]. Forgot the link... https://lore.kernel.org/all/YcG32Ytj0zUAW%2FB2@hirez.programming.kicks-ass.net/ > Paravirt features that communicate between guest and host via memory is the other > case that often maps a pfn into KVM. > > > Without being able to specifically state what should be avoided, a flag like > > that would be difficult for userspace to use. > > Yeah :-( I was thinking KVM could state the flag would be safe to use if and only > if userspace could guarantee that the guest would use the memory for some "special" > use case, but hadn't actually thought about how to word things. > > The best thing to do is probably to wait for for kvm_vcpu_map() to be eliminated, > as described in the changelogs for commits: > > 357a18ad230f ("KVM: Kill kvm_map_gfn() / kvm_unmap_gfn() and gfn_to_pfn_cache") > 7e2175ebd695 ("KVM: x86: Fix recording of guest steal time / preempted status") > > Once that is done, everything in KVM will either access guest memory through the > userspace hva, or via a mechanism that is tied into the mmu_notifier, at which > point accessing non-refcounted struct pages is safe and just needs to worry about > not corrupting _refcount. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel