From patchwork Thu Aug 24 15:25:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jinoh Kang X-Patchwork-Id: 13364349 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 2ED37C71153 for ; Thu, 24 Aug 2023 15:26:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.590149.922266 (Exim 4.92) (envelope-from ) id 1qZCDY-0003qj-1s; Thu, 24 Aug 2023 15:25:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 590149.922266; Thu, 24 Aug 2023 15:25:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qZCDX-0003qW-Td; Thu, 24 Aug 2023 15:25:51 +0000 Received: by outflank-mailman (input) for mailman id 590149; Thu, 24 Aug 2023 15:25:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qZCDX-0003YG-08 for xen-devel@lists.xenproject.org; Thu, 24 Aug 2023 15:25:51 +0000 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [2607:f8b0:4864:20::42e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8020759a-4292-11ee-9b0c-b553b5be7939; Thu, 24 Aug 2023 17:25:48 +0200 (CEST) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68a4bcf8a97so3503314b3a.1 for ; Thu, 24 Aug 2023 08:25:49 -0700 (PDT) Received: from [10.137.0.57] ([14.33.99.107]) by smtp.gmail.com with ESMTPSA id a7-20020a170902ecc700b001b2069072ccsm12937709plh.18.2023.08.24.08.25.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Aug 2023 08:25:47 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8020759a-4292-11ee-9b0c-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692890748; x=1693495548; h=content-transfer-encoding:in-reply-to:content-language:references :cc:subject:from:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=Gl1uSk6cql3DTrfRNGOLaEQ10Vv8LUbqQ//89vIyzb8=; b=AY01yRMuYtAmiu92yTvpMOTNoj/Adx2YB0agM8mAQI8m6cBDwcotG7QiNIHKmQgGgm h9IdGWPKCLXiiDH/1cvTT87X/zsVNIrIm1BZNK3cndyAZFt/tA7uMDoyz5e1VmC3fJt8 dX6UJrAPbJ3vDIetTsPBNmSmhh6qbKd0Sxnp6s3dfrSRn/kw817tHn+7sVXaVXxoBxNs GzZWpvYYa1qKdBWSLWbHU4SrvGlU7AFcuGN6nM3NDFRt3FIg7g0ugvYMxKCMyIKq/Fig auvQdNlCyx10gFKGHZqIjnYJ71GmTnynm2MuvgnV7mN4LvF3beHIbMvyYvppwOpIeTMT 5Pfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692890748; x=1693495548; h=content-transfer-encoding:in-reply-to:content-language:references :cc:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gl1uSk6cql3DTrfRNGOLaEQ10Vv8LUbqQ//89vIyzb8=; b=TU7PtTyFOFUgvpFee2kz9wHYYgDiLcP4LjMyxOG7sb/8CGcVgb0KFkX2lz+IzVSFRD Xw7O/75BdEhhoeWbyQX5NaV5f3QexIBCrocWgrjK7raqxWwbVobRu7OofWJn+9NCUXku MwUjRwa0gobPKGnZ8NNks/0uE3cynfVPzYB81/tqqeIWIFimmUCT+fhYAFsegreRiix+ 0Aj+CkjUoWj7C6eJY5+1t3eVKmf1oZGVThP9jbX1it3zZRFoPZjYRj+0AbLUaWp6rdd4 isOf0uSeyfaJWNgBa4dn1aJDmqHl2PUiDYHnz4icz2PAyeGkYnD4LRRl2A40tn7NMNb6 Zc1g== X-Gm-Message-State: AOJu0YzBMr5Km7sHtrqsr72qBAaS99w9+ZEAHLJvi52CDAHl6XLPFfUy QVmDQjPzz7LE4JQPCVk4G4s= X-Google-Smtp-Source: AGHT+IHqIJVwaKLxuEl54tRyNpEYhjtCZry0YPvF1C/MyjxUoO4jectbyIT4f1UzRQsd2YXNFOmHnA== X-Received: by 2002:a05:6a20:6d9d:b0:12e:98a3:77b7 with SMTP id gl29-20020a056a206d9d00b0012e98a377b7mr10918296pzb.59.1692890747798; Thu, 24 Aug 2023 08:25:47 -0700 (PDT) Message-ID: Date: Fri, 25 Aug 2023 00:25:41 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 From: Jinoh Kang Subject: [PATCH v2 2/8] x86/hvm: Only populate info->cr2 for #PF in hvm_get_pending_event() Cc: Andrew Cooper , Jan Beulich , Wei Liu , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu , xen-devel@lists.xenproject.org References: <21cc28b9-91d1-1e6e-23ac-00c44f3ec08e@gmail.com> Content-Language: en-US In-Reply-To: <21cc28b9-91d1-1e6e-23ac-00c44f3ec08e@gmail.com> Prepare for an upcoming patch that overloads the 'cr2' field for #DB. Signed-off-by: Jinoh Kang --- CC: Andrew Cooper CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné CC: Tamas K Lengyel CC: Alexandru Isaila CC: Petre Pircalabu --- xen/arch/x86/hvm/hvm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 66ead0b878..c726947ccb 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -503,9 +503,14 @@ void hvm_migrate_pirqs(struct vcpu *v) static bool hvm_get_pending_event(struct vcpu *v, struct x86_event *info) { - info->cr2 = v->arch.hvm.guest_cr[2]; + if ( !alternative_call(hvm_funcs.get_pending_event, v, info) ) + return false; + + if ( info->type == X86_EVENTTYPE_HW_EXCEPTION && + info->vector == X86_EXC_PF ) + info->cr2 = v->arch.hvm.guest_cr[2]; - return alternative_call(hvm_funcs.get_pending_event, v, info); + return true; } void hvm_do_resume(struct vcpu *v)