lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <23a76ce3-d568-3c73-eecc-fa499aeecfcd@linux.intel.com>
Date:   Thu, 8 Sep 2022 16:45:02 -0700
From:   Sathyanarayanan Kuppuswamy 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
To:     Wander Lairson Costa <wander@...hat.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        Shuah Khan <shuah@...nel.org>,
        "H . Peter Anvin" <hpa@...or.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
        Tony Luck <tony.luck@...el.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Kai Huang <kai.huang@...el.com>,
        Isaku Yamahata <isaku.yamahata@...il.com>,
        marcelo.cerri@...onical.com, tim.gardner@...onical.com,
        khalid.elmously@...onical.com, philip.cox@...onical.com,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        linux-doc@...r.kernel.org
Subject: Re: [PATCH v12 2/3] selftests: tdx: Test TDX attestation GetReport
 support



On 9/8/22 7:16 AM, Wander Lairson Costa wrote:
>> +#ifdef DEBUG
>> +static void print_array_hex(const char *title, const char *prefix_str,
>> +		const void *buf, int len)
>> +{
>> +	const __u8 *ptr = buf;
>> +	int i, rowsize = HEX_DUMP_SIZE;
>> +
>> +	if (!len || !buf)
>> +		return;
>> +
>> +	printf("\t\t%s", title);
>> +
>> +	for (i = 0; i < len; i++) {
>> +		if (!(i % rowsize))
>> +			printf("\n%s%.8x:", prefix_str, i);
>> +		printf(" %.2x", ptr[i]);
>> +	}
>> +
>> +	printf("\n");
>> +}
>> +#endif
>> +
>> +TEST(verify_report)
>> +{
>> +	__u8 reportdata[TDX_REPORTDATA_LEN];
>> +	struct tdreport tdreport;
>> +	struct tdx_report_req req;
>> +	int devfd, i;
>> +
>> +	devfd = open(TDX_GUEST_DEVNAME, O_RDWR | O_SYNC);
>> +
>> +	ASSERT_LT(0, devfd);
>> +
>> +	/* Generate sample report data */
>> +	for (i = 0; i < TDX_REPORTDATA_LEN; i++)
>> +		reportdata[i] = i;
>> +
>> +	/* Initialize IOCTL request */
>> +	req.subtype     = 0;
>> +	req.reportdata  = (__u64)reportdata;
>> +	req.rpd_len     = TDX_REPORTDATA_LEN;
>> +	req.tdreport    = (__u64)&tdreport;
>> +	req.tdr_len     = sizeof(tdreport);
>> +
>> +	/* 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
> 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.

Currently, DEBUG is a macro, so we cannot use if (DEBUG) directly.
You are suggesting to change DEBUG to a variable? Any reason to
make this change? I think both changes are functionally similar.
So I am wondering why to make this change?

> 

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ