From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web12.213.1587746239755999692 for ; Fri, 24 Apr 2020 09:37:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SjWpR2gx; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587746238; h=from:from: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; bh=sBLXma/YPQ052hitEKcvKbNkqmyOTDzWC2pOnAPwP9s=; b=SjWpR2gxpA6cQGH+EUs4lEoI0wMCwEGOo3uQTIhkS1EajOWzR8xzvl6kMm1pNyaEYva/BD HOfE0DnqnIqecSvxiczr0M3cpA9PUStK2NwzqAV+gqmjtQB8NizyF8PkDxv/dbwXM3KJI9 fezcOvkeD8MOF7se/JAn2eozjXk83hM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-u8DnvRaHMyqTSd2Cjb99cg-1; Fri, 24 Apr 2020 12:37:11 -0400 X-MC-Unique: u8DnvRaHMyqTSd2Cjb99cg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EE58107ACCD; Fri, 24 Apr 2020 16:37:10 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-159.ams2.redhat.com [10.36.113.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F2F45C1D0; Fri, 24 Apr 2020 16:37:09 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/MpInitLib: Restore IDT context for APs. To: devel@edk2.groups.io, eric.dong@intel.com Cc: Ray Ni , Chandana Kumar References: <20200422090111.423-1-eric.dong@intel.com> From: "Laszlo Ersek" Message-ID: <8a20a87a-330b-0330-d182-85b4cfb4a27c@redhat.com> Date: Fri, 24 Apr 2020 18:37:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200422090111.423-1-eric.dong@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 04/22/20 11:01, Dong, Eric wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2683 > > This patch fixes an assertion because AP can't find the CpuMpData. > When AP is waken up through Init-Sipi-Sipi, AP's IDT should > be restored to pre-allocated buffer so AP can get the CpuMpData > through the IDT base address. > Current code already has logic to handle this when CpuMpData-> > InitFlag is ApInitConfig but misses the logic > when CpuMpData->InitFlag is ApInitReconfig. > This patch fixes this gap. > > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Chandana Kumar > Signed-off-by: Eric Dong > --- > V2: > 1. Enhance code comments. > > UefiCpuPkg/Library/MpInitLib/MpLib.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 64a4c3546e..2e87aa1f06 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -692,6 +692,16 @@ ApWakeupFunction ( > // > RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].VolatileRegisters, TRUE); > } else { > + if (CpuMpData->InitFlag == ApInitReconfig) { > + // > + // Initialize AP volatile registers in ApInitReconfig path. > + // ApInitReconfig happens when: > + // 1. AP is re-enabled after it's disabled, in either PEI or DXE phase. > + // 2. AP is initialized in DXE phase. > + // > + RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, FALSE); > + } > + > // > // The CPU driver might not flush TLB for APs on spot after updating > // page attributes. AP in mwait loop mode needs to take care of it when > Thanks for spelling out the scenarios when this code path could be taken. None of both cases seem to apply to OVMF (CPUs are initialized by CpuMpPei, and I don't think I've ever tested CPI disable/enable). So I don't expect any regression here. Acked-by: Laszlo Ersek Thanks Laszlo