From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EA78D21D492DE for ; Wed, 13 Sep 2017 09:30:49 -0700 (PDT) Received: from G2W6310.americas.hpqcorp.net (g2w6310.austin.hp.com [16.197.64.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2353.austin.hpe.com (Postfix) with ESMTPS id 64F58AA; Wed, 13 Sep 2017 16:33:47 +0000 (UTC) Received: from G4W9122.americas.hpqcorp.net (2002:10d2:1511::10d2:1511) by G2W6310.americas.hpqcorp.net (2002:10c5:4034::10c5:4034) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 13 Sep 2017 16:33:47 +0000 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (15.241.52.13) by G4W9122.americas.hpqcorp.net (16.210.21.17) with Microsoft SMTP Server (TLS) id 15.0.1178.4 via Frontend Transport; Wed, 13 Sep 2017 16:33:46 +0000 Received: from DF4PR84MB0155.NAMPRD84.PROD.OUTLOOK.COM (10.162.192.29) by DF4PR84MB0315.NAMPRD84.PROD.OUTLOOK.COM (10.162.193.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Wed, 13 Sep 2017 16:33:44 +0000 Received: from DF4PR84MB0155.NAMPRD84.PROD.OUTLOOK.COM ([10.162.192.29]) by DF4PR84MB0155.NAMPRD84.PROD.OUTLOOK.COM ([10.162.192.29]) with mapi id 15.20.0056.010; Wed, 13 Sep 2017 16:33:44 +0000 From: "Johnson, Brian (EXL - Eagan)" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Justen@ml01.01.org" , Eric Dong , "Kinney@ml01.01.org" , Jordan L , "Wolman@ml01.01.org" , Jiewen Yao , Ayellet , Michael D , Laszlo Ersek , Star Zeng Thread-Topic: [edk2] [PATCH 4/4] OvmfPkg/QemuVideoDxe: Update QemuVideoDxe driver to bypass NULL pointer detection if enabled. Thread-Index: AQHTLHJNGr4fA1D1skaggpFr6cHp6qKzAu6A Date: Wed, 13 Sep 2017 16:33:44 +0000 Message-ID: References: <20170913092507.12504-1-jian.j.wang@intel.com> <20170913092507.12504-5-jian.j.wang@intel.com> In-Reply-To: <20170913092507.12504-5-jian.j.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=brian.johnson@hpe.com; x-originating-ip: [192.48.192.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DF4PR84MB0315; 6:Hubii9O9Ru9OMzWqg9C1sHX3Nc/4pKRP0KvqSSLUwj5K3q2/3VhafK1/IfYr/kXudHm1iY/zLNiX2F9Y621qZTTLmYCRo6lUf4dQ3LSmWTm5kzyX6w3k2RfW5QcaH3PrOAIrO1sSfZLM3O4XUGIbEqQ3tookmeHvMuiG/WUBpJq2y2Vy1tfph125G2hvhZk6z76svyUQnJ3vXgttFd5ODRiPTQNqdKNXpZickVtuLSycOESe3VSByZgTgNOsrpMY2BaEgwqTNQKnxeIh3jULmFpOpkyN9n3/g3463ZNDKlDfn5tKmaEasbQmC5V6zvN4WiW4WzxsdXJtWRfSqehOSA==; 5:6OBFFyciTaXliz3WIuAHdmeDL6qDkxUnSGKZyYkoZ0RXJtAo03xV6OFGDG2wA6K4hMYu95UqGD+swbCwd0d7fMPJx38Sqqn1mXi+nL7nVmGo3QK8yzthZuH7l4ZWKDXX+fXzlpY5Ku9YVlJ4PslGDg==; 24:SpAeBmvaGjBQOnZgm8LRgA8C5k74NLsqb248JW5yzL62wHJ4GqsbH9gQIPNEWxPUy9RZlWlhqnICeBdl3NonpsQHedpq85ijbx51/B6gOR8=; 7:66WaqXP7TND+0cniAENOtDA0pSLUYV7PvXsC3NDO/wgCH1AMqHrg/nb4gWo9iyE6KMGWAkIxxWcsNg3AxOQ+PMGyzI7JeV25/qbNItiE1jsZ6V5dXjkGbHkfQvtDSVcbxzs1YVdydtCW3/wGFCcM4xTglPy8ikhmkxQbiDLb9mlahqLSBDanMAZmoorgtuDCZYxAuZiLCp9v6KQaN1lc6hgfRZ8j2xcE2VX/FTnAeoY= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 647d2d91-ae16-4748-6fb7-08d4fac5337d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DF4PR84MB0315; x-ms-traffictypediagnostic: DF4PR84MB0315: x-exchange-antispam-report-test: UriScan:(227479698468861)(162533806227266)(228905959029699); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DF4PR84MB0315; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DF4PR84MB0315; x-forefront-prvs: 042957ACD7 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(366002)(346002)(376002)(13464003)(377454003)(199003)(189002)(74316002)(4326008)(9686003)(6306002)(6246003)(33656002)(7736002)(305945005)(53936002)(102836003)(6116002)(8676002)(3846002)(81166006)(81156014)(68736007)(55016002)(3660700001)(54906002)(3280700002)(189998001)(66066001)(2906002)(8936002)(229853002)(6436002)(77096006)(14454004)(2900100001)(5660300001)(53546010)(97736004)(316002)(106356001)(105586002)(7416002)(6506006)(2950100002)(7696004)(54356999)(76176999)(50986999)(478600001)(575784001)(25786009)(15650500001)(86362001)(101416001)(966005)(2501003); DIR:OUT; SFP:1102; SCL:1; SRVR:DF4PR84MB0315; H:DF4PR84MB0155.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Sep 2017 16:33:44.4192 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0315 X-OriginatorOrg: hpe.com Subject: Re: [PATCH 4/4] OvmfPkg/QemuVideoDxe: Update QemuVideoDxe driver to bypass NULL pointer detection if enabled. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Sep 2017 16:30:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Brian J. Johnson -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Wang= , Jian J Sent: Wednesday, September 13, 2017 4:25 AM To: edk2-devel@lists.01.org Cc: Justen@ml01.01.org; Eric Dong ; Kinney@ml01.01.org= ; Jordan L ; Wolman@ml01.01.org; Jiewen Yao ; Ayellet ; Michael D ; Laszlo Ersek ; Star Zeng Subject: [edk2] [PATCH 4/4] OvmfPkg/QemuVideoDxe: Update QemuVideoDxe drive= r to bypass NULL pointer detection if enabled. QemuVideoDxe driver will install VBE SHIM into page 0. If NULL pointer dete= ction is enabled, page 0 must be enabled temporarily before installing and = disabled again afterwards. For Windows 7 boot, BIT7 of PcdNullPointerDetect= ionPropertyMask must still be set to avoid hang. Cc: Jiewen Yao Cc: Eric Dong Cc: Star Zeng Cc: Laszlo Ersek Cc: Justen, Jordan L Cc: Kinney, Michael D Cc: Wolman, Ayellet Suggested-by: Wolman, Ayellet Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wang, Jian J --- OvmfPkg/QemuVideoDxe/Driver.c | 15 ++++++++++++++- OvmfPkg/QemuVideoDxe/Qemu.h | 16 ++++++++++++++++ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c index 0dce80e59b..ee0eed7214 100644 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ b/OvmfPkg/QemuVideoDxe/Driver.c @@ -194,6 +194,7 @@ QemuVideoControllerDriverStart ( PCI_TYPE00 Pci; QEMU_VIDEO_CARD *Card; EFI_PCI_IO_PROTOCOL *ChildPciIo; + EFI_CPU_ARCH_PROTOCOL *Cpu; =20 OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 @@ -479,7 +480,19 @@ QemuVideoControllerDriverStart ( #if defined MDE_CPU_IA32 || defined MDE_CPU_X64 if (Private->Variant =3D=3D QEMU_VIDEO_BOCHS_MMIO || Private->Variant =3D=3D QEMU_VIDEO_BOCHS) { - InstallVbeShim (Card->Name, Private->GraphicsOutput.Mode->FrameBufferB= ase); + // + // Prepare CPU arch protocol for NULL pointer detection + // + Status =3D gBS->LocateProtocol ( + &gEfiCpuArchProtocolGuid, + NULL,=20 + (VOID **) &Cpu + ); + ASSERT_EFI_ERROR (Status); + + DISABLE_NULL_DETECTION(Cpu); + InstallVbeShim (Card->Name, Private->GraphicsOutput.Mode->FrameBuffe= rBase); + ENABLE_NULL_DETECTION(Cpu); } #endif =20 diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h index 7fbb25b3ef..bb3bc6eb0f 100644 --- a/OvmfPkg/QemuVideoDxe/Qemu.h +++ b/OvmfPkg/QemuVideoDxe/Qemu.h @@ -25,6 +25,7 @@ #include #include #include +#include =20 #include #include @@ -82,6 +83,21 @@ typedef struct { =20 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff =20 +// +// VBE code will access memory between 0-4095 which will cause page fault = exception=20 +// if NULL pointer detection mechanism is enabled. Following macros can be= used to=20 +// disable/enable NULL pointer detection before/after accessing those memo= ry. +// +#define NULL_DETECTION_ENABLED ((PcdGet8(PcdNullPointerDetectionPropertyM= ask) & (BIT0|BIT7)) =3D=3D BIT0) +#define DISABLE_NULL_DETECTION(Cpu) = \ + if (NULL_DETECTION_ENABLED) { = \ + (Cpu)->SetMemoryAttributes((Cpu), 0, EFI_PAGE_SIZE, 0); = \ + } +#define ENABLE_NULL_DETECTION(Cpu) = \ + if (NULL_DETECTION_ENABLED) { = \ + (Cpu)->SetMemoryAttributes((Cpu), 0, EFI_PAGE_SIZE, EFI_MEMORY_RP); = \ + } + // // QEMU Video Private Data Structure // diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/Q= emuVideoDxe.inf index 7c7d429bca..5d166eb99c 100644 --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf @@ -72,7 +72,9 @@ gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START gEfiDevicePathProtocolGuid # PROTOCOL BY_START gEfiPciIoProtocolGuid # PROTOCOL TO_START + gEfiCpuArchProtocolGuid =20 [Pcd] gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion + gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask =20 --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel