Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3696122ybv; Mon, 10 Feb 2020 04:53:34 -0800 (PST) X-Google-Smtp-Source: APXvYqyJgI7DKsHr0hg8cJtfTjutHQmSNXUpiQcIBrrnsjgrAeuuWSpPqb4YpceClAzBefsMdrKh X-Received: by 2002:aca:cf07:: with SMTP id f7mr733798oig.5.1581339214496; Mon, 10 Feb 2020 04:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339214; cv=none; d=google.com; s=arc-20160816; b=btU+F3dKuukgOOc8URBvFT+wlfdqF3nhvlYqmn8+n7BgMaqahnNJzj8CfYIF2lxmCo v0UQWOvFZtOMvY+3sH1ustBFpJWmbD2C4sPOY4EClnmuEL0xSZTJu7tJbqYKsufzlMd2 6ta5YBL+Z76VkP55VpKuh6y540SQLQYnetr8FXhSngPp2nPDgckKT5LpXhQZENrjSfVR JT8Oqk6W94QD/fNMsWnbbvS8YiQQWtt7fCLxXGQYUky2j0nkk2/WfK53IuNcOVfh3ooM ZFbswlgboWJndokohpsrGemwNx1WupAGQsn3NWbPQROqFzezAfWq9UhJck5gb/TG2BcY tV0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lOUGJ2vovztxdmhPWm9Q4mxH/NNFMDyWvs3qGzl9eLc=; b=UwFiUYa7RH/69hGTO+7IOtpAgyr9qim4kUb7atrq8VKDU/2gOYnd/M79fucc8TLh/T r4diKmVmRF3Gb5ijGL1MEiD5YYX3GxenDLwgryMIDMzpvJdnuYoeVxrG7aWZoEi3n8l3 aDRLukpZRvfbTWYsAZ34aikxaqvKc2Z++QFfwmMVvbdgNzAvdZIMlAyIOVxRLaS2MXNt Qp8TSyFVpzfbBLkQsyNP77MedYjMPcCVzEbAidY0tJMli+JVP/S0vh3DGed5avm7aSe8 rkyn+EBM6Y4S5cyhKBB1N+yRWnZwIIFpg3dYYdr6Vw0fjBysX7xmZSMptTsQtWXFxGaM eOkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zw3pk42t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si124933oti.306.2020.02.10.04.53.23; Mon, 10 Feb 2020 04:53:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zw3pk42t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729525AbgBJMxT (ORCPT + 99 others); Mon, 10 Feb 2020 07:53:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:46212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729857AbgBJMmN (ORCPT ); Mon, 10 Feb 2020 07:42:13 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B29F2085B; Mon, 10 Feb 2020 12:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338533; bh=lsrYIvTCKm6UNqj2q/1UKHaCwzyVnZJCvOu7RzNSAD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zw3pk42tJ/yONhmzA1pbog4Cnm84UFoPB9YqFqTQn8C2/26L2F33vvIvMavuvAj3a YnKemuD4zcieWnzmBnELzMdVVwKiezHPPtKx4er8W372/gE1lm14V2kijTbXc/Ff6N bqTcq0senMyr47sGQvCadOULZV45zoETvZcdc1q0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.5 359/367] KVM: Play nice with read-only memslots when querying host page size Date: Mon, 10 Feb 2020 04:34:32 -0800 Message-Id: <20200210122455.534464170@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit 42cde48b2d39772dba47e680781a32a6c4b7dc33 ] Avoid the "writable" check in __gfn_to_hva_many(), which will always fail on read-only memslots due to gfn_to_hva() assuming writes. Functionally, this allows x86 to create large mappings for read-only memslots that are backed by HugeTLB mappings. Note, the changelog for commit 05da45583de9 ("KVM: MMU: large page support") states "If the largepage contains write-protected pages, a large pte is not used.", but "write-protected" refers to pages that are temporarily read-only, e.g. read-only memslots didn't even exist at the time. Fixes: 4d8b81abc47b ("KVM: introduce readonly memslot") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson [Redone using kvm_vcpu_gfn_to_memslot_prot. - Paolo] Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index cb1a4bbe3b30f..2b3f36df3d855 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1413,7 +1413,7 @@ unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn) size = PAGE_SIZE; - addr = kvm_vcpu_gfn_to_hva(vcpu, gfn); + addr = kvm_vcpu_gfn_to_hva_prot(vcpu, gfn, NULL); if (kvm_is_error_hva(addr)) return PAGE_SIZE; -- 2.20.1