From: "Huang, Kai" <kai.huang@intel.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: "linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"seanjc@google.com" <seanjc@google.com>,
"luto@kernel.org" <luto@kernel.org>,
"Hansen, Dave" <dave.hansen@intel.com>,
"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
"Huang, Haitao" <haitao.huang@intel.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"jethro@fortanix.com" <jethro@fortanix.com>,
"b.thiel@posteo.de" <b.thiel@posteo.de>
Subject: RE: [RFC PATCH v5 06/26] x86/cpu/intel: Allow SGX virtualization without Launch Control support
Date: Tue, 16 Feb 2021 10:24:06 +0000 [thread overview]
Message-ID: <6875a6542c534a4fbe8dd1c17fd077a5@intel.com> (raw)
In-Reply-To: <YCuEHJ7a2HLG6jk/@kernel.org>
> > > >
> > > > + enable_vmx = cpu_has(c, X86_FEATURE_VMX) &&
> > > > + IS_ENABLED(CONFIG_KVM_INTEL);
> > >
> > > It's less than 100 characters:
> >
> > Just carious, shouldn't be 80 characters to wrap a new line, instead of 100?
>
> Try with checkpatch.pl.
Checkpatch.pl has default value 100, but it can be overwritten. I found below document explicitly said 80 should be the length:
https://www.kernel.org/doc/html/v5.11-rc7/process/coding-style.html
2) Breaking long lines and strings
Coding style is all about readability and maintainability using commonly available tools.
The preferred limit on the length of a single line is 80 columns.
Statements longer than 80 columns should be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information.
[...]
> > > > update_sgx:
> > > > - if (!(msr & FEAT_CTL_SGX_ENABLED) ||
> > > > - !(msr & FEAT_CTL_SGX_LC_ENABLED) || !enable_sgx) {
> > > > - if (enable_sgx)
> > > > - pr_err_once("SGX disabled by BIOS\n");
> > > > + if (!(msr & FEAT_CTL_SGX_ENABLED)) {
> > > > + if (enable_sgx_kvm || enable_sgx_driver)
> > > > + pr_err_once("SGX disabled by BIOS.\n");
> > > > clear_cpu_cap(c, X86_FEATURE_SGX);
> > >
> > > Empty line before return statement.
> >
> > It's just two statements inside the if() {} statement. Putting a new line here is
> too sparse IMHO.
> >
> > I'd like to hear more.
>
> This was a common review comment in original SGX series, so I'm sticking to the
> pattern.
Well if you insist, I can do that.
But I am not that convinced. In fact, I also believe that in most cases, having empty line before 'return' is good practice, for instance, when 'return' is the very last statement in the function.
I am also glad to do it if it is a x86 patch convention that we even need to put a new empty line when there are only very few statements inside if() {}. However it seems it is not the case.
For example, I just did a search in SGX driver code, and below examples all DONOT have empty line before return (and I don't think I captured them all):
sgx/driver.c:
static int sgx_release(struct inode *inode, struct file *file)
{
......
kref_put(&encl->refcount, sgx_encl_release);
return 0;
}
sgx/ioctl.c:
static struct sgx_va_page *sgx_encl_grow(struct sgx_encl *encl)
{
......
va_page->epc_page = sgx_alloc_va_page();
if (IS_ERR(va_page->epc_page)) {
err = ERR_CAST(va_page->epc_page);
kfree(va_page);
return err;
}
WARN_ON_ONCE(encl->page_cnt % SGX_VA_SLOT_COUNT);
}
encl->page_cnt++;
return va_page;
}
static long sgx_ioc_enclave_create(struct sgx_encl *encl, void __user *arg)
{
......
kfree(secs);
return ret;
}
static int sgx_encl_add_page(struct sgx_encl *encl, unsigned long src,
unsigned long offset, struct sgx_secinfo *secinfo,
unsigned long flags)
{
......
epc_page = sgx_alloc_epc_page(encl_page, true);
if (IS_ERR(epc_page)) {
kfree(encl_page);
return PTR_ERR(epc_page);
}
......
sgx_mark_page_reclaimable(encl_page->epc_page);
mutex_unlock(&encl->lock);
mmap_read_unlock(current->mm);
return ret;
......
}
And in cpu/feat_ctl.c:
void init_ia32_feat_ctl(struct cpuinfo_x86 *c)
{
......
if (rdmsrl_safe(MSR_IA32_FEAT_CTL, &msr)) {
clear_cpu_cap(c, X86_FEATURE_VMX);
clear_sgx_caps();
return;
}
......
}
next prev parent reply other threads:[~2021-02-16 10:25 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-13 13:28 [RFC PATCH v5 00/26] KVM SGX virtualization support Kai Huang
2021-02-13 13:28 ` [RFC PATCH v5 01/26] x86/cpufeatures: Make SGX_LC feature bit depend on SGX bit Kai Huang
2021-02-13 13:28 ` [RFC PATCH v5 02/26] x86/cpufeatures: Add SGX1 and SGX2 sub-features Kai Huang
2021-02-13 13:28 ` [RFC PATCH v5 03/26] x86/sgx: Wipe out EREMOVE from sgx_free_epc_page() Kai Huang
2021-02-16 17:04 ` Dave Hansen
2021-02-16 20:42 ` Huang, Kai
2021-02-13 13:28 ` [RFC PATCH v5 04/26] x86/sgx: Add SGX_CHILD_PRESENT hardware error code Kai Huang
2021-02-13 13:28 ` [RFC PATCH v5 05/26] x86/sgx: Introduce virtual EPC for use by KVM guests Kai Huang
2021-02-16 2:12 ` Jarkko Sakkinen
2021-02-16 18:38 ` Dave Hansen
2021-02-16 19:25 ` Sean Christopherson
2021-02-16 21:33 ` Huang, Kai
2021-02-16 21:34 ` Huang, Kai
2021-02-17 22:22 ` Jarkko Sakkinen
2021-02-13 13:29 ` [RFC PATCH v5 06/26] x86/cpu/intel: Allow SGX virtualization without Launch Control support Kai Huang
2021-02-16 2:15 ` Jarkko Sakkinen
2021-02-16 5:03 ` Huang, Kai
2021-02-16 8:36 ` Jarkko Sakkinen
2021-02-16 10:24 ` Huang, Kai [this message]
2021-02-16 18:40 ` Dave Hansen
2021-02-16 20:42 ` Huang, Kai
2021-02-13 13:29 ` [RFC PATCH v5 07/26] x86/sgx: Initialize virtual EPC driver even when SGX driver is disabled Kai Huang
2021-02-16 18:41 ` Dave Hansen
2021-02-13 13:29 ` [RFC PATCH v5 08/26] x86/sgx: Expose SGX architectural definitions to the kernel Kai Huang
2021-02-16 2:17 ` Jarkko Sakkinen
2021-02-16 10:30 ` Huang, Kai
2021-02-16 10:32 ` Borislav Petkov
2021-02-16 11:15 ` Huang, Kai
2021-02-16 11:48 ` Borislav Petkov
2021-02-16 11:56 ` Huang, Kai
2021-02-16 15:18 ` Dave Hansen
2021-02-16 18:47 ` Borislav Petkov
2021-02-16 18:53 ` Dave Hansen
2021-02-16 19:18 ` Borislav Petkov
2021-02-17 22:20 ` Jarkko Sakkinen
2021-02-18 9:09 ` Huang, Kai
2021-02-16 16:28 ` Jarkko Sakkinen
2021-02-13 13:29 ` [RFC PATCH v5 09/26] x86/sgx: Move ENCLS leaf definitions to sgx_arch.h Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 10/26] x86/sgx: Add SGX2 ENCLS leaf definitions (EAUG, EMODPR and EMODT) Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 11/26] x86/sgx: Add encls_faulted() helper Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 12/26] x86/sgx: Add helper to update SGX_LEPUBKEYHASHn MSRs Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 13/26] x86/sgx: Add helpers to expose ECREATE and EINIT to KVM Kai Huang
2021-02-16 3:08 ` Jarkko Sakkinen
2021-02-16 3:09 ` Jarkko Sakkinen
2021-02-16 4:55 ` Huang, Kai
2021-02-16 8:33 ` Jarkko Sakkinen
2021-02-16 8:35 ` Jarkko Sakkinen
2021-02-16 9:33 ` Huang, Kai
2021-02-13 13:29 ` [RFC PATCH v5 14/26] x86/sgx: Move provisioning device creation out of SGX driver Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 15/26] KVM: VMX: Convert vcpu_vmx.exit_reason to a union Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 16/26] KVM: x86: Export kvm_mmu_gva_to_gpa_{read,write}() for SGX (VMX) Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 17/26] KVM: x86: Define new #PF SGX error code bit Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 18/26] KVM: x86: Add support for reverse CPUID lookup of scattered features Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 19/26] KVM: x86: Add reverse-CPUID lookup support for scattered SGX features Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 20/26] KVM: VMX: Add basic handling of VM-Exit from SGX enclave Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 21/26] KVM: VMX: Frame in ENCLS handler for SGX virtualization Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 22/26] KVM: VMX: Add SGX ENCLS[ECREATE] handler to enforce CPUID restrictions Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 23/26] KVM: VMX: Add emulation of SGX Launch Control LE hash MSRs Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 24/26] KVM: VMX: Add ENCLS[EINIT] handler to support SGX Launch Control (LC) Kai Huang
2021-02-13 13:29 ` [RFC PATCH v5 25/26] KVM: VMX: Enable SGX virtualization for SGX1, SGX2 and LC Kai Huang
2021-02-13 13:30 ` [RFC PATCH v5 26/26] KVM: x86: Add capability to grant VM access to privileged SGX attribute Kai Huang
2021-02-16 18:48 ` [RFC PATCH v5 00/26] KVM SGX virtualization support Dave Hansen
2021-02-16 19:15 ` Sean Christopherson
2021-02-16 20:58 ` Huang, Kai
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=6875a6542c534a4fbe8dd1c17fd077a5@intel.com \
--to=kai.huang@intel.com \
--cc=b.thiel@posteo.de \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=haitao.huang@intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=jethro@fortanix.com \
--cc=kvm@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).