[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/6] x86/prot-key: Split PKRU infrastructure out of asm/processor.h


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 9 Jan 2023 17:30:21 +0100
  • 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
  • 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=VgMU/SgV6KX0g0UGb94kr9WJ66aNKxszDwcL6jaddWQ=; b=FszD5OIaCx1xFPdMxglqcygRyVkvtpM0CzZzosp1ot8qsZhy9vTN2e+Ae+V7hyQDqSHafr3ntNXbhGUSFq0e6+v0J4NaDZKKQMwMciZuH+9s1y7LFpONvX8zKtmydwvJjdHXrQnBUzPnIN1NoLA8+oqas/N5akwoDngc44Fek+ItQ+trCY5e0gnq1/ZSeaaoA8XoiYatvMQ6PvK7O5ckcprrw388/8rI121gJEHSN5VB0180EXsdZ4agO7CVBfUGcpGwEqoVaRz/hHsr/WSGK/eNrWhEmUHSqxXDNFmPiGQGcKLMh3nlKMIqaQxXSvdFxQmc2I3emQm/FTXhOGIskQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P08qqfpkV3nR2yLxeo2XiTX3EaTtPuUaTcZvOnfdakfF1TDN9MWn2flYaMXEQIMRVCK2GurN5tnFxcRJ3Is9lOqP9RwxL3ZjbfjfkDueRoo4nnFDPzwoKY/m84NNQRd45qvVL9q/uWNtk6sXw4q+JqLurJFUkbvoFW3yqznsCfXWMFr5OeXTKUqBhVudlNIXttNuxJASFoYriEaoYZwSbNRbvqm/uK6SB9DrKD6DzDxPEI662cSav/cCqZc0Z6wabJ3lZ4Q1g9CpJB1TjPl0N0F8oU43gLINPkCk2ks1ynXIS1F1EDKIK7kCTTtUjuQ+XgIUwZ9cneiyaJxk12Xytw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 09 Jan 2023 16:30:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09.01.2023 15:57, Andrew Cooper wrote:
> On 21/12/2021 11:28 am, Jan Beulich wrote:
>> On 16.12.2021 10:54, Andrew Cooper wrote:
>>> --- /dev/null
>>> +++ b/xen/arch/x86/include/asm/prot-key.h
>>> @@ -0,0 +1,45 @@
>>> +/******************************************************************************
>>> + * arch/x86/include/asm/spec_ctrl.h
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + *
>>> + * You should have received a copy of the GNU General Public License
>>> + * along with this program; If not, see <http://www.gnu.org/licenses/>.
>>> + *
>>> + * Copyright (c) 2021 Citrix Systems Ltd.
>>> + */
>>> +#ifndef ASM_PROT_KEY_H
>>> +#define ASM_PROT_KEY_H
>>> +
>>> +#include <xen/types.h>
>>> +
>>> +#define PKEY_AD 1 /* Access Disable */
>>> +#define PKEY_WD 2 /* Write Disable */
>>> +
>>> +#define PKEY_WIDTH 2 /* Two bits per protection key */
>>> +
>>> +static inline uint32_t rdpkru(void)
>>> +{
>>> +    uint32_t pkru;
>> I agree this wants to be uint32_t (i.e. unlike the original function),
>> but I don't see why the function's return type needs to be, the more
>> that the sole caller also uses unsigned int for the variable to store
>> the result in.
> 
> This is thinnest-possible wrapper around an instruction which
> architecturally returns exactly 32 bits of data.
> 
> It is literally the example that CODING_STYLE uses to demonstrate when
> fixed width types should be used.

I don't read it like that, but I guess we're simply drawing the line in
different places (and agreeing on one place would be nice). To me using
uint32_t for a variable accessed by an asm() is what is meant. But that
then (to me) doesn't extend to the function return type here.

But no, I don't mean to block this change just because of this aspect.
We've got many far worse uses of types, which bother me more. It merely
would be nice if new code (regardless of the contributor) ended up all
consistent in this regard.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.