From patchwork Mon Jun 12 04:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13275557 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FAB8C7EE25 for ; Mon, 12 Jun 2023 04:50:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D53D56B0072; Mon, 12 Jun 2023 00:50:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CDCB26B0074; Mon, 12 Jun 2023 00:50:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B55FB8E0002; Mon, 12 Jun 2023 00:50:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9FAB36B0072 for ; Mon, 12 Jun 2023 00:50:58 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 74B68AE324 for ; Mon, 12 Jun 2023 04:50:58 +0000 (UTC) X-FDA: 80892870996.14.97D38BD Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2042.outbound.protection.outlook.com [40.107.102.42]) by imf14.hostedemail.com (Postfix) with ESMTP id 6E2BC100006 for ; Mon, 12 Jun 2023 04:50:55 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=UUfF3W1y; spf=pass (imf14.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.102.42 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1686545455; a=rsa-sha256; cv=pass; b=IaK1/9VNmbKHkH2d6rVcwDxtGl2kHmhRFhWjvBIYA405Tb6D9xuLl17LKb6+JRKecbyVgf U6rUoHkMPQtqTVZM/xPcOzGk7CMx9KqxQYZPfxfoHJBnbwRzpP90W7rOEjEXWj8qSeJzbV XcHR8DbYz9iaGFosMPCLtvQnGED8jXc= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=UUfF3W1y; spf=pass (imf14.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.102.42 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686545455; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s218HDiFv2eZBxy4ZcFM21BtWf4J8w71c4nYAY2Bnnc=; b=DO9vNFGXo5zimc1ejYZyTOnLsDCnMkA7k2Pijwj8gghYu6uSfDCYH4BbNG9UaJ0QAv0f44 8psDAZDXJ2CgNDGvOZqFjyfA1A+x2VfCd3S4H3fkxV8ZjkoP9NykwZAyQ0hOCuUkmL10vw mGvH2bfmFXxfAbI52XPnYknBU8wj+P8= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hr9K7FC9j34n1LlFCJy9piR1fC7/nj9koxs6u3uWx9oKk4+w+U3uBCiClu1tSv3/f8mv1hDyDGgkwlozBKTjkP/kgTdqkU1IYn+FlBrBzhPD4yShw6aumeabJ3qtCEB13n1IqUizVqC1zeQJD3FcjbwFRzgj5kdPpPPBfbCZiAURce8AoNJX0GdPp0d0pfu7GdpJ6uvwWNnqKoxw4iU/hVQ8jIO4hMYDP36o8DydfV80kbAogiznQHxHChRDlnCiTkGM0/wpcMWIZZdKC+kFjCjdcjOCg9Q8PUP/o/hwDtWGNhskmYieTAe7mr0BWN/1eRyMbHAqOEKN/quVCcC+nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s218HDiFv2eZBxy4ZcFM21BtWf4J8w71c4nYAY2Bnnc=; b=HfFEeFtEQ7p3hTNnj1KWhxvfNIzmoqIxB0egB/sUd5xtuHuCQzmb0NL/RGr7liBuSxUP2ipSzLFuWMWINNYSU9SDlNHvKLIBppBzu9CXDh2cZfAn/4wsCMSbddkf/EKZKGskMg4U4z3ADt/FsHVAZwoXjaktcYL7TAJjTTic2gHxFOLWIrMYQEL0T9Q7Jp5jyIrnYo0x44F9j5cBtRy8ZXd9ZjRCcCJGOyLLW4ASCkIddtF4uNI2/vge9kz4zoiYkVOwuiwAZ4zvxjw5r2qRASaUp+GW6lZyruQK8Y8TU5buctMJ7y1oQvlx5URDXti+fz0hJW8TfBGeAjYRGB7XYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s218HDiFv2eZBxy4ZcFM21BtWf4J8w71c4nYAY2Bnnc=; b=UUfF3W1yo8GdhhtHwYnzq4wvAkKs6xROhS4NVgnunYA5lqMw34ZLZeZkIl8cajtZzRhGa6aBLUYTGCdqhqISsv3NdqAhmGkzW4g/Ux5G2osXh1sZ0C+zv/S1WhXEQAImVAZCrUnN0Onz0q8oAIZyiuwyZBQLLaZY3XNqWoOBqpA= Received: from SA1PR05CA0002.namprd05.prod.outlook.com (2603:10b6:806:2d2::8) by DM4PR12MB8475.namprd12.prod.outlook.com (2603:10b6:8:190::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Mon, 12 Jun 2023 04:50:49 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:2d2:cafe::86) by SA1PR05CA0002.outlook.office365.com (2603:10b6:806:2d2::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.22 via Frontend Transport; Mon, 12 Jun 2023 04:50:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.22 via Frontend Transport; Mon, 12 Jun 2023 04:50:48 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sun, 11 Jun 2023 23:48:05 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RFC v9 03/51] KVM: x86: Use full 64-bit error code for kvm_mmu_do_page_fault Date: Sun, 11 Jun 2023 23:25:11 -0500 Message-ID: <20230612042559.375660-4-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230612042559.375660-1-michael.roth@amd.com> References: <20230612042559.375660-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|DM4PR12MB8475:EE_ X-MS-Office365-Filtering-Correlation-Id: 66e8f260-5b71-4611-a0c9-08db6b009782 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aDTmU/JF0XyDbGUVKUj65tBEtjtLuT5BwMkK4wsD/2Ki/WhY9VFnF6Rq49Y75ezZ7cTxNJ+WZf7sVCbJXTP0HvFMwXNNoTRn1R6m2DX1ig5NleoiLUUBzYLNwkhlqnTcQN2eLxC3FIdE8jCf6MA2X5+W9fBtzcFY5k43YvJpIXuyP1pXsr9VqZIfex4qbTED18c8HVoAIobgk0PYNqq4zKxIF+7cKR/Way2gOI1KOCcXIhbEHXOjv/y5tLVxRa3fbUOTp26MoooeFiv7kChTmEB+PQE1fPU0wXFxHs6vdThFVM3In3HrCpdxfa2qrPL2/JCf6PKXMKmJAiUEAR+jbXUvl+qAVQILrlEYj35BwOme/tCm9QLUVVmPfdPyCtPeEIxNn+V21acxnF1uBg4SNW8LRk4IOiY98tl/GIPTDV4e3UcAXOq9MEMt8JmjccGfjRzhQX755kZMazURioKJkTkaYJvo9iTER/p2irw6pMnoYXDwS4MKaACC//GE1/nWVVu8CiN1aeX5KqTjN6ETW3GcLk54PMT+JhACavujG4KJ3SinBUmZw34DXS9qtzRZX/4cib8DsIxRdG8cxaaw3ow5vEO985Lx7U44XFHNgGjFhca7M1msx2dOgIe/TcRP8oAELulRsjAJg8Wh78+5+uJoPvdBLm/SerfqU0oZiAFLNjVY74lPnK8ZxHnAFemamNFMC2syWhpG6UKgtBWVDHuAApurLbcwtXXzF7QUwS3tocuMXsNxFDeEtCRD4wrv/HAOPYFV8vaxHcYKih5sCA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(426003)(336012)(2616005)(47076005)(83380400001)(36860700001)(356005)(82740400003)(40480700001)(36756003)(86362001)(82310400005)(81166007)(40460700003)(478600001)(54906003)(44832011)(6666004)(8936002)(8676002)(2906002)(5660300002)(7416002)(7406005)(70206006)(70586007)(4326008)(6916009)(41300700001)(316002)(186003)(16526019)(1076003)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 04:50:48.8524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66e8f260-5b71-4611-a0c9-08db6b009782 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8475 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6E2BC100006 X-Stat-Signature: cjp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76sAk+FTBHJQtTcnQkbq4FStChiiW7hscfS5pcncsgknXQ2sdhdWLuS81dbvxdO0Ctz28+8ENM87bclK1rEl9IT6FpTVf/0x3glU/qRzr7S9G+GDR0Bv4QgkYHnCmsYqt6Z+b2kTc1xoZnkBrIono8UeEdqMRs9Ykj0mn6Vh5ER3HTPrZlCBRRyyt1H5sFIAOcGyU9bT1mtCA7GujJNSKn8elQ5NCVDmKPjIsDTvelGIdOk1iRlzlZwWwUyhxSn97NB/jyVJgW294yEZsLZleUG/O4FJmKOwIoOwSqi/Fj6PKbtn5jbwMhQXivSyEqurX2W6BHYgu07D99hYJ4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The upper bits will be needed in some cases to distinguish between nested page faults for private/shared pages, so pass along the full 64-bit value. Signed-off-by: Michael Roth Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 3 +-- arch/x86/kvm/mmu/mmu_internal.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index c54672ad6cbc..0d3983b9aa7e 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5829,8 +5829,7 @@ int noinline kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 err } if (r == RET_PF_INVALID) { - r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, - lower_32_bits(error_code), false, + r = kvm_mmu_do_page_fault(vcpu, cr2_or_gpa, error_code, false, &emulation_type); if (KVM_BUG_ON(r == RET_PF_INVALID, vcpu->kvm)) return -EIO; diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index f1786698ae00..780b91e1da9f 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -283,11 +283,11 @@ enum { }; static inline int kvm_mmu_do_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, - u32 err, bool prefetch, int *emulation_type) + u64 err, bool prefetch, int *emulation_type) { struct kvm_page_fault fault = { .addr = cr2_or_gpa, - .error_code = err, + .error_code = lower_32_bits(err), .exec = err & PFERR_FETCH_MASK, .write = err & PFERR_WRITE_MASK, .present = err & PFERR_PRESENT_MASK,