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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 19AEFC433E0 for ; Mon, 1 Feb 2021 13:55:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7EAF64E97 for ; Mon, 1 Feb 2021 13:55:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbhBANzx (ORCPT ); Mon, 1 Feb 2021 08:55:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:49072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbhBANzw (ORCPT ); Mon, 1 Feb 2021 08:55:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E0C9B64D9D; Mon, 1 Feb 2021 13:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612187711; bh=dmMa6igSrfr8Kqr11tNDaLEvYhkM+qbuD/1gq1a+Pp8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d9OMeoSn54heoMcY93O8Sy1eY721FH6QtFz00ZXp8ZGiMQMkGCDPYcmWheefS5PI6 3jqsL16flnObQNxUGRQ8ox/U0Q6bamMm9xcMqtcEPCan52yhV4bbAWWVI0DWM/q2J8 DVVuk0GCVkslZKKb7uCZ97lTb0xv/44ZES64p5QU= Date: Mon, 1 Feb 2021 14:55:08 +0100 From: Greg KH To: Paolo Bonzini Cc: Marc Zyngier , stable@vger.kernel.org, kvm@vger.kernel.org, Rick Edgecombe , Catalin Marinas Subject: Re: [stable-5.4][PATCH] KVM: Forbid the use of tagged userspace addresses for memslots Message-ID: References: <20210201133137.3541896-1-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Feb 01, 2021 at 02:38:05PM +0100, Paolo Bonzini wrote: > On 01/02/21 14:31, Marc Zyngier wrote: > > commit 139bc8a6146d92822c866cf2fd410159c56b3648 upstream. > > > > The use of a tagged address could be pretty confusing for the > > whole memslot infrastructure as well as the MMU notifiers. > > > > Forbid it altogether, as it never quite worked the first place. > > > > Cc: stable@vger.kernel.org > > Reported-by: Rick Edgecombe > > Reviewed-by: Catalin Marinas > > Signed-off-by: Marc Zyngier > > --- > > Documentation/virt/kvm/api.txt | 3 +++ > > virt/kvm/kvm_main.c | 1 + > > 2 files changed, 4 insertions(+) > > > > diff --git a/Documentation/virt/kvm/api.txt b/Documentation/virt/kvm/api.txt > > index a18e996fa54b..7064efd3b5ea 100644 > > --- a/Documentation/virt/kvm/api.txt > > +++ b/Documentation/virt/kvm/api.txt > > @@ -1132,6 +1132,9 @@ field userspace_addr, which must point at user addressable memory for > > the entire memory slot size. Any object may back this memory, including > > anonymous memory, ordinary files, and hugetlbfs. > > +On architectures that support a form of address tagging, userspace_addr must > > +be an untagged address. > > + > > It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr > > be identical. This allows large pages in the guest to be backed by large > > pages in the host. > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index 8f3b40ec02b7..f25b5043cbca 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -1017,6 +1017,7 @@ int __kvm_set_memory_region(struct kvm *kvm, > > /* We can read the guest memory with __xxx_user() later on. */ > > if ((id < KVM_USER_MEM_SLOTS) && > > ((mem->userspace_addr & (PAGE_SIZE - 1)) || > > + (mem->userspace_addr != untagged_addr(mem->userspace_addr)) || > > !access_ok((void __user *)(unsigned long)mem->userspace_addr, > > mem->memory_size))) > > goto out; > > > > Indeed untagged_addr was added in 5.3. > > Acked-by: Paolo Bonzini Now queued up, thanks. greg k-h