From: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Wander Lairson Costa <wander@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, Shuah Khan <shuah@kernel.org>,
"H . Peter Anvin" <hpa@zytor.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Tony Luck <tony.luck@intel.com>, Andi Kleen <ak@linux.intel.com>,
Kai Huang <kai.huang@intel.com>,
Isaku Yamahata <isaku.yamahata@gmail.com>,
marcelo.cerri@canonical.com, tim.gardner@canonical.com,
khalid.elmously@canonical.com, philip.cox@canonical.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v12 2/3] selftests: tdx: Test TDX attestation GetReport support
Date: Thu, 8 Sep 2022 18:55:53 -0700 [thread overview]
Message-ID: <e4b6f718-d671-72b3-4c4d-4338feba80a1@linux.intel.com> (raw)
In-Reply-To: <Yxn5VDzJMUxSKz0Z@fedora>
On 9/8/22 7:16 AM, Wander Lairson Costa wrote:
> You can unconditionally define print_array_hex, and
> use `if (DEBUG)` instead of #ifdef `DEBUG here`. The compiler
> will get rid of the unused code when DEBUG is not defined
> as expected, but you get the parser to validate it
> independent of the definition of DEBUG.
To avoid #ifdef DEBUG in multiple places, we can try following
change. Let me know your comments.
--- a/tools/testing/selftests/tdx/tdx_attest_test.c
+++ b/tools/testing/selftests/tdx/tdx_attest_test.c
@@ -21,6 +21,14 @@
#define HEX_DUMP_SIZE 8
#define __packed __attribute__((packed))
+static inline int _no_printf(const char *format, ...) { return 0; }
+
+#ifdef DEBUG
+#define pr_debug(...) printf(__VA_ARGS__)
+#else
+#define pr_debug(...) _no_printf(__VA_ARGS__)
+#endif
+
/*
* Trusted Execution Environment (TEE) report (TDREPORT_STRUCT) type,
* sub type and version. More details can be found in TDX v1.0 Module
@@ -90,7 +98,6 @@ struct tdreport {
struct td_info tdinfo;
} __packed;
-#ifdef DEBUG
static void print_array_hex(const char *title, const char *prefix_str,
const void *buf, int len)
{
@@ -100,17 +107,16 @@ static void print_array_hex(const char *title, const char *prefix_str,
if (!len || !buf)
return;
- printf("\t\t%s", title);
+ pr_debug("\t\t%s", title);
for (i = 0; i < len; i++) {
if (!(i % rowsize))
- printf("\n%s%.8x:", prefix_str, i);
- printf(" %.2x", ptr[i]);
+ pr_debug("\n%s%.8x:", prefix_str, i);
+ pr_debug(" %.2x", ptr[i]);
}
- printf("\n");
+ pr_debug("\n");
}
-#endif
TEST(verify_report)
{
@@ -139,13 +145,11 @@ TEST(verify_report)
/* Get TDREPORT */
ASSERT_EQ(0, ioctl(devfd, TDX_CMD_GET_REPORT, &req));
-#ifdef DEBUG
print_array_hex("\n\t\tTDX report data\n", "",
reportdata, sizeof(reportdata));
print_array_hex("\n\t\tTDX tdreport data\n", "",
&tdreport, sizeof(tdreport));
-#endif
/* Make sure TDREPORT data includes the REPORTDATA passed */
ASSERT_EQ(0, memcmp(&tdreport.reportmac.reportdata[0],
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
next prev parent reply other threads:[~2022-09-09 1:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 0:27 [PATCH v12 0/3] Add TDX Guest Attestation support Kuppuswamy Sathyanarayanan
2022-09-08 0:27 ` [PATCH v12 1/3] x86/tdx: Add TDX Guest attestation interface driver Kuppuswamy Sathyanarayanan
2022-09-08 5:31 ` Greg Kroah-Hartman
2022-09-08 19:07 ` Sathyanarayanan Kuppuswamy
2022-09-08 20:36 ` Dave Hansen
2022-09-08 20:45 ` Sathyanarayanan Kuppuswamy
2022-09-09 5:26 ` Greg Kroah-Hartman
2022-09-08 23:53 ` Sathyanarayanan Kuppuswamy
2022-09-09 5:25 ` Greg Kroah-Hartman
2022-09-08 0:27 ` [PATCH v12 2/3] selftests: tdx: Test TDX attestation GetReport support Kuppuswamy Sathyanarayanan
2022-09-08 14:16 ` Wander Lairson Costa
2022-09-08 23:45 ` Sathyanarayanan Kuppuswamy
2022-09-09 13:36 ` Wander Lairson Costa
2022-09-09 18:40 ` Sathyanarayanan Kuppuswamy
2022-09-09 1:55 ` Sathyanarayanan Kuppuswamy [this message]
2022-09-09 13:49 ` Dave Hansen
2022-09-09 3:48 ` Huang, Kai
2022-09-09 5:08 ` Sathyanarayanan Kuppuswamy
2022-09-08 0:27 ` [PATCH v12 3/3] Documentation/x86: Document TDX attestation process Kuppuswamy Sathyanarayanan
2022-09-08 9:10 ` Bagas Sanjaya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e4b6f718-d671-72b3-4c4d-4338feba80a1@linux.intel.com \
--to=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=isaku.yamahata@gmail.com \
--cc=kai.huang@intel.com \
--cc=khalid.elmously@canonical.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=mingo@redhat.com \
--cc=philip.cox@canonical.com \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=tim.gardner@canonical.com \
--cc=tony.luck@intel.com \
--cc=wander@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox