From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.47]) by mx.groups.io with SMTP id smtpd.web11.104983.1671027860319909853 for ; Wed, 14 Dec 2022 06:24:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@suse.com header.s=selector1 header.b=diO+mhS4; spf=pass (domain: suse.com, ip: 40.107.14.47, mailfrom: jlee@suse.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=URv4MdcBZOw/QcBkIye5JpRdHdV9tZvm9A77aJMHQld+iIbGsaEz1DWTY05sSgfZjqRPni+jAZaGUduJMNY2qtOM+EUj1KzEV9xzMX2wF7Xle6eMnkL0OblBE22VyGnKTlPh8v6wG+USMtbjfZySEd1gOO0J0xLSyMiJZH57Kq1mhDrR492xGCM6xqipJqclz0N3tS2mFfDF2uaRZPC7Dlv0zhPJOgblLTYL4NswRZDsLa2kyJrfOrMDNGRKvLa3jC26sgdTNtrE6t2l3UtmyNg9M6VeJjs88KPWxsyWQTX+gUMIy4FpXM9T24Jsxs5VUoPK1yTVnrT/cQXykUdTCA== 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=2UA4hv8A/Lxqjn3rafgXCdoTJQHlXzKXFqUJh9coVAg=; b=E35QiUBKjHFdgPEV6rtmZGXzjgKAcFrz5oSSuNkgSxG/Zd4hM3bb4bOB5IU5OoJqTb39TQawuuv+UHGq+sq8uq9MOtm4i62GePjr/IeIq19BMUXBcz2rNE5rOmUR2QDU8iDZa0WuG7xEH+TJFY+jozg07o1+I4X9pNX7g+72+3jljYLdSZQJ8ePLU3x8tj5PQgqDVB/VQXxblSexLkeBRq80w/EAYC2q6Q3y1w7gliYJMMa4oU6sr61XYhmltKbfJ+6uVHWXLwAC0YJRtL3Qm9R7EP7BccvU/uawSeck6H3WfqeKjnWCBf9XgOCNHfjpTQBOpmZctArdizMXtV020g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2UA4hv8A/Lxqjn3rafgXCdoTJQHlXzKXFqUJh9coVAg=; b=diO+mhS4KbQJ/DGB/kcs18thhE+amjLiW/EOqMqiVtLsf2zsF7WOX+X8PeTAqTcl1p0AiS4UiDP6IIy1zmUZWHrpUIBRarC4k2uhAASRUELFNMgsw3F4JiCfQglPZGwoQ0wgbMUo3eFRUzD0y3R93cKPDQ/98P8j/UjW8naUkcCj0WYVfjeeUR/QOUD7TkuilMZpvD5ZKTrf0IPYbbHJxVEJzqNp/pj36TJCUzL6TPmXHnCkukg4yzzoZsc8NEIWWdOzDti1c5q4l1qnm8y7SCLk1qcqNP38l+Vu2SU7TJO+XM+eHOVekHQHXQsWXo4jJUaz4diMXldIs8iKPdmxWQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) by PA4PR04MB8048.eurprd04.prod.outlook.com (2603:10a6:102:c4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10; Wed, 14 Dec 2022 14:24:17 +0000 Received: from DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::3cc9:78f1:6e76:b1ef]) by DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::3cc9:78f1:6e76:b1ef%5]) with mapi id 15.20.5880.019; Wed, 14 Dec 2022 14:24:17 +0000 Date: Wed, 14 Dec 2022 22:24:01 +0800 From: "joeyli" To: devel@edk2.groups.io, kraxel@redhat.com Cc: "Lee, Chun-Yi" , Min M Xu , Jiewen Yao , Tom Lendacky , James Bottomley , Erdem Aktas Subject: Re: [edk2-devel] [PATCH] OvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore in some cases Message-ID: <20221214142401.GZ11807@linux-l9pv.suse> References: <20221213155502.29548-1-jlee@suse.com> <20221214061528.zi627mkk4mumtdoo@sirius.home.kraxel.org> <20221214134516.GY11807@linux-l9pv.suse> In-Reply-To: <20221214134516.GY11807@linux-l9pv.suse> User-Agent: Mutt/1.11.4 (2019-03-13) X-ClientProxiedBy: TYBP286CA0024.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:ce::36) To DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) Return-Path: JLee@suse.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR04MB7164:EE_|PA4PR04MB8048:EE_ X-MS-Office365-Filtering-Correlation-Id: 11d19376-890c-453b-b4ca-08dadddee1ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lPSMKNd5AeJ3zvyYxA2YU8F3eM+7p1CcWyjTj9Zzg+XYORovkShTVC0s2i7nuobhXHRN5H6A8jjEMxDHxP//EyLNpqTRE0qkUJ6sMeWXaJbdWRqTaEpFqKALvt1Ow7jGGKwXbH3o5OE5SZqYB8aJ2AK/meibFI5kzBleFBO9mfpzd3QbjqwVoHCnkJh8wjLv1cVehSWriHDyx5bMwL67hq06sw7KUGVuvxvMSSvctYwmJx0MBJmeyVoYD/kE3CwBIvQN5dtZYlms787MPGuPbVKjiXnNkZ4zEfT544zBxfrliAmtHThT0pqZ1xFFjyJ5gfe8SRAPyCkL88clV0oty/52h23y4Ox4IuxCotrJE9eQyGdAjj2yaqHAglpQC03A60+8B14qisrVoiSLXckkdl/sWBwjXean7fv9ze/0k5mmr6SRvYTp4iOaaC3EMi5Q428VJVdFY9Af07Arj8t/bf+s//Hax16kAEdNcoMmK25xpTUPt2xrBarFcBVm4GKD0N3cLI/gv8uykTS3umcZ7AikOAUZVsGy5rhNteYsPXVALoi6fhaMScoeVrPQpxrMA1piga7FddE8Ob9dD3O2ZoWoS/tcAc1RIyy7pwdlfSOwp1H6mbdS4GvNz4KNF3Gq6KXQC8J/h3jeE/6y6LOTX2cFM/OKn4VxZFjYNqYQ8hWxvXIKsZDacrNLvSfXMgJ6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB7164.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(6029001)(366004)(346002)(396003)(136003)(376002)(39860400002)(451199015)(66946007)(36756003)(54906003)(6506007)(316002)(2906002)(6666004)(66476007)(66556008)(8936002)(6486002)(6512007)(86362001)(1076003)(186003)(26005)(9686003)(33656002)(83380400001)(478600001)(5660300002)(38100700002)(19627235002)(4326008)(8676002)(41300700001)(43062005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?P9tk3G9OuPghWwDWdjt7QP+dORGWyEwTfn9nuLn2xJI4NBdYOzE+u0jCdPUL?= =?us-ascii?Q?jgKgrgx0jaaKENl0oJkGOrySDrvtmJRgV5efD9Dbeb1HfAiz96UCUm/g81+M?= =?us-ascii?Q?v0qWaSIACmvP3fHH4kuRBlIisKf+0qH6wiRnNSNrUB79Wq1ivirsCG9OP1+O?= =?us-ascii?Q?wfy3giVuKeygev950ABfRUFp94AUA/fs8LanTSX2tG7jrMdG2Kp+tJeqiJ1s?= =?us-ascii?Q?OC7bF/b1AZwZBPSxqQsiT7NvgEy4rGtFROYgyW+1Vv/h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v1Jguh6P0EU3QZt84fT97BPu83pkTua9?= =?us-ascii?Q?dYaqm2BOWFOPWLd3s5RYFgjtDrkbZg7+5EqSN7Oe4MwDHATqoMkeLYpDMReI?= =?us-ascii?Q?hgFZTqS0RorXUCk2BYwq5hdEjlXC3ZuQpNj2czcX+qUEGPQALke77biCkFd4?= =?us-ascii?Q?8FkahM9oajkfHC3OsZNhUw9N4LLhF0VITb8qvPNx0MDg9uzVYLAvP1tijx3P?= =?us-ascii?Q?OtaTkW8WaulDm4TCeu7eDuxq9K/JTGQ9DOMwkr0rUpPG4r++u36yKIF0Odkv?= =?us-ascii?Q?Gta4aYQZ3H+8U28Efv22HZCR0+YxBnTYU6cIDDqijMeIeAqU+m9W8wIyBHHf?= =?us-ascii?Q?voqk2N0Wc+oenM+ADW4270Jbqp4N0eiUeh+SDBqR4NFAWOefG4z8RdpK0d1Z?= =?us-ascii?Q?SQqmQCP66dWWleE4lwqQ6U6WAodo6A7uRpeMGwsy?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11d19376-890c-453b-b4ca-08dadddee1ef X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB7164.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 14:24:17.0501 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QG83rKs8IF//5dma6shy0tqsCjStwTJn+9iXA1wjU7R3cGEgNe+ApJhXNLEeN70k X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB8048 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Wed, Dec 14, 2022 at 09:46:36PM +0800, joeyli wrote: > Hi Gerd, > > Thanks for your response! > > On Wed, Dec 14, 2022 at 07:15:28AM +0100, Gerd Hoffmann via groups.io wrote: > > Hi, > > > > > When the variable store has those variables, then system booting/rebooting will > > > hangs in a ASSERT: > > > > > > NvVarStore Variable header State was invalid. > > > ASSERT > > > /mnt/working/source_code-git/edk2/OvmfPkg/Library/PlatformInitLib/Platform.c(819): > > > ((BOOLEAN)(0==1)) > > > > I'm wondering how you manage to trigger this assert? > > > > Sorry for I forgot to put my testing environment in patch description. > My testing is on qemu with OVMF: > > - edk2-master or edk2-stable202211 > build --verbose --debug=1 -D SECURE_BOOT_ENABLE -D TPM_ENABLE -D TPM_CONFIG_ENABLE \ > -D NETWORK_IP6_ENABLE -D NETWORK_HTTP_BOOT_ENABLE -a X64 -b DEBUG -t GCC5 \ > -p OvmfPkg/OvmfPkgX64.dsc -D FD_SIZE_4MB -D NETWORK_TLS_ENABLE > > - qemu-7.1.0 with libvirt-8.0.0 > pc-q35 with pflash type and nvram: > hvm > /usr/share/qemu/ovmf-x86_64-code.bin > /var/lib/libvirt/qemu/nvram/opensuseTW_VARS.fd > > - grub2 2.06 and Linux kernel 6.1.0-rc5 > I forgot shim-15.7, the fallback mechanism created new boot entry and update bootorder in a new *_VARS.fd : FSOpen: Open '\EFI\opensuse\boot.csv' Success UpdateVariable() - Boot0003, 8BE4DF61-93CA-11D2-AA0D-00E098032B8C FlushHobVariableToFlash() - Boot0003, 8BE4DF61-93CA-11D2-AA0D-00E098032B8C UpdateVariable() - BootOrder, 8BE4DF61-93CA-11D2-AA0D-00E098032B8C L1870, State = 0x3F State &= VAR_DELETED = 0x3D <-- state of BootOrder FlushHobVariableToFlash() - BootOrder, 8BE4DF61-93CA-11D2-AA0D-00E098032B8C Joey Lee > Two test cases, both of them can reproduce the assert: > > - First booting to grub2 menu, then "virsh destroy" the guest. > The second boot hangs in the "NvVarStore Variable header State was invalid." assert > > - First boot to Linux kernel 6.1.0-rc5, bash shell prompt shows up. > Then run shutdown or reboot command. > The second boot hangs in in the "NvVarStore Variable header State was invalid." assert > > > > Adding more log to UpdateVariable() and PlatformValidateNvVarStore(), we > > > can see there have some variables have 0x3C or 0x3D state in store. > > > e.g. > > > > PlatformValidateNvVarStore() validates the varstore in ROM before > > copying it to RAM. The normal UpdateVariable() cycle changes the > > copy in RAM ... > > > > Yes, in the first boot, those variables have 0x3C or 0x3C state be > created. After shutdown or reboot, system hangs in the second boot. > The assert shows up in debug log. > > Thanks a lot! > Joey Lee