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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <da2d332a-6d30-c102-9aa0-328d98401dae@linux.intel.com>
Date:   Thu, 1 Apr 2021 15:25:20 -0700
From:   "Kuppuswamy, Sathyanarayanan" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
To:     Dave Hansen <dave.hansen@...el.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Andy Lutomirski <luto@...nel.org>
Cc:     Andi Kleen <ak@...ux.intel.com>,
        Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
        Kuppuswamy Sathyanarayanan <knsathya@...nel.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Raj Ashok <ashok.raj@...el.com>,
        Sean Christopherson <seanjc@...gle.com>,
        linux-kernel@...r.kernel.org,
        Sean Christopherson <sean.j.christopherson@...el.com>
Subject: Re: [RFC v1 03/26] x86/cpufeatures: Add is_tdx_guest() interface



On 4/1/21 2:19 PM, Dave Hansen wrote:
> On 4/1/21 2:15 PM, Kuppuswamy, Sathyanarayanan wrote:
>> On 4/1/21 2:08 PM, Dave Hansen wrote:
>>> On 2/5/21 3:38 PM, Kuppuswamy Sathyanarayanan wrote:
>>>> +bool is_tdx_guest(void)
>>>> +{
>>>> +    return static_cpu_has(X86_FEATURE_TDX_GUEST);
>>>> +}
>>>
>>> Why do you need is_tdx_guest() as opposed to calling
>>> cpu_feature_enabled(X86_FEATURE_TDX_GUEST) everywhere?
>>
>> is_tdx_guest() is also implemented/used in compressed
>> code (which uses native_cpuid calls). I don't think
>> we can use cpu_feature_enabled(X86_FEATURE_TDX_GUEST) in
>> compressed code right? Also is_tdx_guest() looks easy
>> to read and use.
> 
> OK, but how many of the is_tdx_guest() uses are in the compressed code?
>   Why has its use spread beyond that?
Its only used in handling in/out instructions in compressed code. But this
code shared with in/out handling on non-compressed code.

#define __out(bwl, bw)                                                  \
do {                                                                    \
         if (is_tdx_guest()) {                                           \
                 asm volatile("call tdg_out" #bwl : :                    \
                                 "a"(value), "d"(port));                 \
         } else {                                                        \
                 asm volatile("out" #bwl " %" #bw "0, %w1" : :           \
                                 "a"(value), "Nd"(port));                \
         }                                                               \
} while (0)
#define __in(bwl, bw)                                                   \
do {                                                                    \
         if (is_tdx_guest()) {                                           \
                 asm volatile("call tdg_in" #bwl :                       \
                                 "=a"(value) : "d"(port));               \
         } else {                                                        \
                 asm volatile("in" #bwl " %w1, %" #bw "0" :              \
                                 "=a"(value) : "Nd"(port));              \
         }                                                               \
} while (0)

> 

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ