Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5458160pxu; Tue, 22 Dec 2020 18:40:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHPdZi/kOHR+Y13cXld48RwkfkQEgB9ID5aueyifGWXFU20ZqVjvml1pOXkZCtP7IqABLW X-Received: by 2002:a50:c053:: with SMTP id u19mr22828043edd.109.1608691224136; Tue, 22 Dec 2020 18:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691224; cv=none; d=google.com; s=arc-20160816; b=SSKBGsCcfJgs7xU44vtU0QRPcyMg798sx+nT2RycKa96ydS77X2RPHzt9RZeD89IM9 o/EMox7I8LWk0hRPJKsPyjfbyHhcz4r0AbGquXXgSQKhTTxckvNpmNHkoAcJGQAe+ELw AEE/qWFFB0JnsQMi9o3J4VV8BIlSlggj1tA/LxIiJqQQvWCjAqiO2UcUGKXvA7Hmnbnt KnTrFOiLZu4CFU2F+jcD6mb68zU2d6t0RUfh1EdPDZoP31golvcl0W0n5+ZoiRm0phyQ ZVShji7KIBCTD7oZMxYkbO5DwflPWSfkWK6khEC8ObiQvjO5+D8ukanaQByBXpyqfmT9 /Uew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ESz5JA5OYpduc3lipDxlM67p7hpR0qbiGoeXITq8gVY=; b=KayiEA+kEKkhxXlKocrBG1GiBVhlmJeIiMTByKCeT3+WOSzvJdnEM/EQVv8YACrZEi xAgQnHKofZqFOFfa1aCJfkRKeXSYuZPcLgqZWm6n/Zcy74oCvAjUIpD1Yibsrujw4jQP tbtn9w52vrTGqx4k7x1i6d0a1ac91xI0KUBLmr0xuSP9ZeagT7/zVyniYJGZ3UuORcpN Zn/DQGjqi1SOvx+D7DLtYOcZ40tpZCfTEBW3mha5E+J1xUeqHnPSayBNpRn6OGY77OBb W6CrxNdWg0Azj3h0Rs4at4J57UdCvM4cFWg3oK+MSiI66hF/dohyDOHzw/i4eZZnR+TE a9gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ov4Iv4jL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l26si13134365edv.316.2020.12.22.18.40.02; Tue, 22 Dec 2020 18:40:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ov4Iv4jL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730864AbgLWCjq (ORCPT + 99 others); Tue, 22 Dec 2020 21:39:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:49658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729002AbgLWCXp (ORCPT ); Tue, 22 Dec 2020 21:23:45 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F33F422D73; Wed, 23 Dec 2020 02:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690209; bh=ttibY4CYcqWLEZB+Pd0wkF+oOxlfdb/3kj1G3780xgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ov4Iv4jLvlNd7czZpNZ9r+g8W+B/Rof3wzOfdykQtfQnZxtlhwBwrU9bkR9gNd0w1 CyngoOjJPLxMHuubj4HNqpy4uli6btIWzcOXNfRuNidMeigtbNqE2dJswyib23duN+ CyLLCscsga+UB7knOvRkVIxAK7/G2ZfJKiMjk3dCdAy8SvN9g9Q22LlZ6Ejh5+7BiC YaFabf8EmR38eOQF7+PBFO3AUr+ac1JqWxOtxVGldWM+Emr439FYMwr3ubXzhqvePY /GWdOidJcLsVr0sQv+ad4MIIL1H3JRqHTvtFjKYChsNuCuwCgocMlcD/k4PpROWYx6 sdR0qidPX+Obg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Bogendoerfer , Sasha Levin , linux-mips@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 29/66] MIPS: kvm: Use vm_get_page_prot to get protection bits Date: Tue, 22 Dec 2020 21:22:15 -0500 Message-Id: <20201223022253.2793452-29-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Bogendoerfer [ Upstream commit 411406a8c758d9ad6f908fab3a6cf1d3d89e1d08 ] MIPS protection bits are setup during runtime so using defines like PAGE_SHARED ignores this runtime changes. Using vm_get_page_prot to get correct page protection fixes this. Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/kvm/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c index ee64db0327933..0e3ad8c0d346a 100644 --- a/arch/mips/kvm/mmu.c +++ b/arch/mips/kvm/mmu.c @@ -1108,6 +1108,7 @@ int kvm_mips_handle_commpage_tlb_fault(unsigned long badvaddr, { kvm_pfn_t pfn; pte_t *ptep; + pgprot_t prot; ptep = kvm_trap_emul_pte_for_gva(vcpu, badvaddr); if (!ptep) { @@ -1117,7 +1118,8 @@ int kvm_mips_handle_commpage_tlb_fault(unsigned long badvaddr, pfn = PFN_DOWN(virt_to_phys(vcpu->arch.kseg0_commpage)); /* Also set valid and dirty, so refill handler doesn't have to */ - *ptep = pte_mkyoung(pte_mkdirty(pfn_pte(pfn, PAGE_SHARED))); + prot = vm_get_page_prot(VM_READ|VM_WRITE|VM_SHARED); + *ptep = pte_mkyoung(pte_mkdirty(pfn_pte(pfn, prot))); /* Invalidate this entry in the TLB, guest kernel ASID only */ kvm_mips_host_tlb_inv(vcpu, badvaddr, false, true); -- 2.27.0