From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.85165.1597829080829464599 for ; Wed, 19 Aug 2020 02:24:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E0gkDHns; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597829080; 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=0hROovFRzxNbDI/XP2vjuxcAvkPWlWAh1PvsWNbKmLQ=; b=E0gkDHnsLuCK3fwgpZaDh4BsSy9D+XGI8qfxV5E1qeb5IExuAzrUfL/BjE8sLgUYSTGjN0 eW1a/Z6BZh3mNs0mGD+LSQR58e3NqhltcNE/GXQCbMi0bRu37w9yg6Yb+r7XPSD/exGJFv sClfIUq5IEBnsg3lNo8Odbr22dQWhIs= 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-193-PRzRuL_rPsqXekmr3UoJVQ-1; Wed, 19 Aug 2020 05:24:33 -0400 X-MC-Unique: PRzRuL_rPsqXekmr3UoJVQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA40310066FB; Wed, 19 Aug 2020 09:24:31 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-57.ams2.redhat.com [10.36.114.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BDCF26DD4; Wed, 19 Aug 2020 09:24:30 +0000 (UTC) Subject: Re: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable To: Tom Lendacky , devel@edk2.groups.io Cc: Liming Gao , Eric Dong , Ray Ni , Rahul Kumar References: <477f5449c898cd96240729105dde26b1fd75baa9.1597756206.git.thomas.lendacky@amd.com> From: "Laszlo Ersek" Message-ID: Date: Wed, 19 Aug 2020 11:24:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <477f5449c898cd96240729105dde26b1fd75baa9.1597756206.git.thomas.lendacky@amd.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 08/18/20 15:10, Tom Lendacky wrote: > From: Tom Lendacky > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2901 > > The DoDecrement variable in ApWakeupFunction () wasn't always being > initialized. Update the code to always fully initialize it. > > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Signed-off-by: Tom Lendacky > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 90416c81b616..e24bdc64f930 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -885,9 +885,7 @@ ApWakeupFunction ( > UINT64 Status; > BOOLEAN DoDecrement; > > - if (CpuMpData->InitFlag == ApInitConfig) { > - DoDecrement = TRUE; > - } > + DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE : FALSE; > > while (TRUE) { > Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB); > Not that I want to obsess about style, but (condition) ? TRUE : FALSE is an anti-patter that's similar to (condition) == TRUE Instead, I suggest: DoDecrement = (BOOLEAN)(CpuMpData->InitFlag == ApInitConfig); (The (BOOLEAN) cast is necessary, or at least used to be necessary, becasue the == operator returns "int" (INT32), but BOOLEAN (i.e., the type of "DoDecrement") is UINT8 -- and some VS toolchains perceive (or used to perceive) this implicit conversion as a "potential loss of precision". That warning is of course bogus, as the == operator only produces 0 or 1, each of which values fits comfortably into a UINT8. But still the explicit (BOOLEAN) cast is how we suppress the warning.) Different question: who's supposed to merge (v2 of) this? Per "Maintainers.txt", it should be Eric or Ray; OTOH, maybe the fix is urgent (build failure with CLANGPDB) and anyone with push access could qualify. Thanks, Laszlo