From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 96CDCD81163 for ; Thu, 29 Feb 2024 13:03:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=PF4AJCee0PSzXSaBkqs9X0ACkIl2Owya6pm9UN2qlS4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1709211787; v=1; b=O6Yh6JSsG4J8QJpFp34F0DcuCf2Htj5bjMFmhzgdw+4a0C9FJfpKYbmYIWGODHRZGLyvXw41 gq4Y2bR8MFTXQvUvpWyTBdrblsZUVXrkJxADrP+lAJ/sAkWlwPf8alAhalZfI2YyK8mF6fobInG qGx4n20IZjTF+r6KfljkHD5Q= X-Received: by 127.0.0.2 with SMTP id rMsaYY7687511xl2zLsfO1CR; Thu, 29 Feb 2024 05:03:07 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by mx.groups.io with SMTP id smtpd.web11.24094.1709211785992876904 for ; Thu, 29 Feb 2024 05:03:06 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3794421" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="3794421" X-Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 05:02:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="8241609" X-Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by orviesa006.jf.intel.com with ESMTP; 29 Feb 2024 05:02:50 -0800 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Laszlo Ersek , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH 1/2] UefiCpuPkg/CpuDxe: Return correct interrupt state Date: Thu, 29 Feb 2024 21:02:45 +0800 Message-Id: <20240229130246.3-2-ray.ni@intel.com> In-Reply-To: <20240229130246.3-1-ray.ni@intel.com> References: <20240229130246.3-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rX7Fkh2Xtdrh3dSyGgmehp03x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=O6Yh6JSs; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) CpuDxe driver uses a global C variable to record the interrupt state. The state variable is updated every time CpuArch.EnableInterrupt() or CpuArch.DisableInterrupt() is called. CpuArch.GetInterruptState() simply returns the state variable. But when CpuArch.GetInterruptState() is called in the interrupt context, even the interrupt state is enabled before interrupt happens, because the interrupt is not disabled through CpuArch.DisableInterrupts(), CpuArch.GetInterruptState() still returns that the interrupt state is enabled. It's not correct. The commit removes the C global variable and always reads the interrupt state from CPU register. Signed-off-by: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/CpuDxe/CpuDxe.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index bf03978710..0349c761ff 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -15,8 +15,7 @@ //=0D // Global Variables=0D //=0D -BOOLEAN InterruptState =3D FALSE;=0D -EFI_HANDLE mCpuHandle =3D NULL;=0D +EFI_HANDLE mCpuHandle =3D NULL;=0D BOOLEAN mIsFlushingGCD;=0D BOOLEAN mIsAllocatingPageTable =3D FALSE;=0D UINT64 mTimerPeriod =3D 0;=0D @@ -89,8 +88,6 @@ CpuEnableInterrupt ( )=0D {=0D EnableInterrupts ();=0D -=0D - InterruptState =3D TRUE;=0D return EFI_SUCCESS;=0D }=0D =0D @@ -110,8 +107,6 @@ CpuDisableInterrupt ( )=0D {=0D DisableInterrupts ();=0D -=0D - InterruptState =3D FALSE;=0D return EFI_SUCCESS;=0D }=0D =0D @@ -136,7 +131,8 @@ CpuGetInterruptState ( return EFI_INVALID_PARAMETER;=0D }=0D =0D - *State =3D InterruptState;=0D + *State =3D GetInterruptState ();=0D +=0D return EFI_SUCCESS;=0D }=0D =0D --=20 2.39.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116166): https://edk2.groups.io/g/devel/message/116166 Mute This Topic: https://groups.io/mt/104642316/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-