After trying different approaches of using clangd with kernel my end game is to put O=./clangd
for the “clangd build”, which is a host (as target) build with bunch of stuff that you want enable. This makes sense because kernel’s .gitignore
has by default .*
.
I also learned that for the “real Vim” (not “Gen Z vim”) there is actually quite decent set of plugins to make use of it. Here’s my vim-plug list:
Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/vim-lsp'
This is how I would ramp up clangd session while hacking Linux:
make ARCH=x86_64 O=./.clangd x86_64_defconfig
make ARCH=x86_64 O=./.clangd menuconfig
make ARCH=x86_64 O=./.clangd -j`nproc`
scripts/clang-tools/gen_compile_commands.py -d ./.clangd
Trying to make a new version of my “TPM2 signers” patch set and stumbling into a weird problem.
Here’s the script I’m looking at:
#!/usr/bin/env bash
set -e
PRIMARY=0x81000001
function egress {
keyctl clear @u
tpm2_evictcontrol -C o -c $PRIMARY 2> /dev/null
tpm2_getcap handles-transient
tpm2_getcap handles-persistent
}
trap egress EXIT
openssl ecparam -name prime256v1 -genkey -noout -out ecc.pem
openssl pkcs8 -topk8 -inform PEM -outform DER -nocrypt -in ecc.pem -out ecc_pkcs8.der
tpm2_createprimary --hierarchy o -G ecc -c owner.txt
tpm2_evictcontrol -c owner.txt $PRIMARY
# EC parameters to TPM2 blob:
tpm2_import -C $PRIMARY -G ecc -i ecc.pem -u tpm2.pub -r tpm2.priv
# TPM2 blob to ASN.1:
tpm2_encodeobject -C $PRIMARY -u tpm2.pub -r tpm2.priv -o tpm2.pem
openssl asn1parse -inform pem -in tpm2.pem -noout -out tpm2.der
# Populate asymmetric keys:
tpm2_ecc_key=`keyctl padd asymmetric "tpm_ecc" @u < tpm2.der`
kernel_ecc_key=`keyctl padd asymmetric "kernel_ecc" @u < ecc_pkcs8.der`
echo "SECRET" > doc.txt
echo TPM2 ECC SIGN
keyctl pkey_sign $tpm2_ecc_key 0 doc.txt hash=sha256 > doc.txt.sig
echo TPM2 VERIFY
keyctl pkey_verify $kernel_ecc_key 0 doc.txt doc.txt.sig
The error message generated is:
keyctl_pkey_verify: Invalid argument
If I verify with the TPM2 ECC key /it will pass, in other words replacing the list statement with:
keyctl pkey_verify $tpm2_ecc_key 0 doc.txt doc.txt.sig hash=sha256
In the final version I’m going to remove signature verification from TPM2 ECC key as that is kind of the point here: sign certificate with a private key protected by TPM and allow any party verify the signature with the known public key.