Skip to content

Instantly share code, notes, and snippets.

@tklengyel
tklengyel / gist:29e9de911f8afe0623ef11cc7fb7f23f
Last active December 6, 2023 00:04
Xen (98758ae48974d6d24f999e4d9324e463d326f66f) cognitive complexity analysis
# apt-get install clang-18 clang-tools-18 clang-tidy-18
# make defconfig
# intercept-build-18 make
# run-clang-tidy-18 -quiet -config="{Checks: 'readability-function-cognitive-complexity', CheckOptions: [{key: readability-function-cognitive-complexity.Threshold, value: 0}, {key: readability-function-cognitive-complexity.DescribeBasicIncrements, value: False}]}" 2>/dev/null | grep warning | grep "cognitive complexity" | tee -a cognitive-complexity.log
arch/x86/acpi/boot.c:63:28: warning: function 'acpi_parse_madt' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
arch/x86/acpi/cpu_idle.c:109:28: warning: function 'parse_cstate' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
arch/x86/acpi/cpu_idle.c:1501:10: warning: function 'pmstat_get_cx_nr' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
arch/x86/acpi/cpu_idle.c:1673:28: warning: function 'cpuidle_presmp_init' has cognitive complexity of 1
### Keybase proof
I hereby claim:
* I am tklengyel on github.
* I am tklengyel (https://keybase.io/tklengyel) on keybase.
* I have a public key ASD50vxdEoWYuReInvNWgepHpXT0_QYaFTTR3NQOnSg9qgo
To claim this, I am signing this object:
0x68747470733a2f2f7777772e796f75747562652e636f6d2f77617463683f763d4854646e4d436b506f3377
root@t2:/shared/xtf# make
root@t2:/shared/xtf# cd tests/kfx
root@t2:/shared/xtf/tests/kfx# xl create -p xen.cfg
Parsing config from xen.cfg
root@t2:/shared/xtf/tests/kfx# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 8192 8 r----- 210894.3
test-pv64-xen-kfx 71 1024 1 --p--- 0.0
root@t2:/shared/xtf/tests/kfx# /shared/kernel-fuzzer-for-xen-project/kfx --setup --domain test-pv64-xen-kfx -c
Init vmi, init_events: 1 init_paging 0 domain test-pv64-xen-kfx domid 0 json (null)
This file has been truncated, but you can view the full file.
diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 9b29769a10..d3f9b7fde5 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -64,13 +64,15 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
total_cpus++;
if ( !enabled )
{
- printk("Skipping disabled CPU entry with 0x%"PRIx64" MPIDR\n", mpidr);
This file has been truncated, but you can view the full file.
diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 9b29769a10..83fe847d67 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -128,7 +128,7 @@ acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
const unsigned long end)
{
struct acpi_madt_generic_interrupt *processor =
- container_of(header, struct acpi_madt_generic_interrupt, header);
@tklengyel
tklengyel / gist:6082a4227ab824cfebd9101e9e8f8095
Last active September 21, 2017 22:29
Compile Linux with initrd and cmdline baked in
Linux initrd and cmdline bake-in (on Debian stretch)
wget https://git.kernel.org/torvalds/t/linux-4.14-rc1.tar.gz
tar xvf linux-4.14-rc1.tar.gz
cp /boot/config-4.9.0-3-amd64 .config
make oldconfig # choosing all default options is fine
make -j8 deb-pkg
sudo dpkg -i ../linux-image-4.14.0-rc1_4.14.0-rc1-1_amd64.deb
mkdir initramfs
@tklengyel
tklengyel / xen_memmap.c
Created August 25, 2017 15:06
Xen foreign memory mapping
/*
* gcc -o xen_memmap -lxenctrl xen_memmap.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#define XC_WANT_COMPAT_MAP_FOREIGN_API 1
#include <xenctrl.h>
int main(int argc, char **argv) {
@tklengyel
tklengyel / bptest.c
Created December 15, 2016 04:40
Make breakpoint instruction (0xCC) length 4
/*
* Make 0xCC instruction length larger then 1
*/
#include <stdio.h>
#include <sys/mman.h>
#include <stdlib.h>
typedef void(*FUN)(void);
char * myFunc;

Keybase proof

I hereby claim:

  • I am tklengyel on github.
  • I am tklengyel (https://keybase.io/tklengyel) on keybase.
  • I have a public key whose fingerprint is 988D 675C 1DA8 BBF5 F3C6 E37C 59DD E405 E032 AC59

To claim this, I am signing this object: