GCC Builtin Constant P and Kernel Optimization

Yesterday a discussion on LKML raised the question if it is possible to disable optimization for kernel build. Sometimes you want to debug the kernel and the required function is optimized out. You are free to disassembly the source code at this place and set the break point manually. But this procedure is time consuming and error prone. I raised another use case: perf probes. Dynamic probepoints placed in the Kernel at runtime....

May 7, 2012 · 2 min · Hagen Paul Pfeifer

Byte Ordering - Again

One practical alternative to #ifdef BIG_ENDIAN bar #else foo #endif clutter in your code are the following two functions. They can always be used, no matter on what architecture the code runs. It always return the correct byte order. uint32\_t le\_pick(char \*data) { return (data[3]<<0) | (data[2]<<8) | (data[1]<<16) | (data[0]<<24); } uint32\_t be\_pick(char \*data) { return (data[0]<<0) | (data[1]<<8) | (data[2]<<16) | (data[3]<<24); } The idea is based on a blog entry from Rob Pike....

May 2, 2012 · 3 min · Hagen Paul Pfeifer

Initial Perf Loop Detection

Arnaldo started to implement initial loop detection in the perf annotate browser. The idea is (was) that backward jumps are mode visible. Currently forward jumps are displayed with some UNICODE character (libslang?): 0,00 │ test %eax,%eax 0,00 │ ↓ je bc 0,00 │ cmpl $0x0,0x4ca034(%rip) # ffffffff81aacb80 <debug\_locks\_silent> 0,00 │ ↓ jne bc 0,00 │ mov $0xbf4,%esi 0,00 │ mov $0xffffffff818039ac,%rdi 0,00 │ callq warn\_slowpath\_null 0,00 │ ↓ jmp bc 12,90 │ 53: mov %gs:0xb760,%rax 4,15 │ add %ebx,-0x1fbc(%rax) 0,00 │ test %edx,%edx 0,00 │ ↓ jne 92 3,69 │ cmpb $0xf4,-0x1fbc(%rax) 0,00 │ ↓ jbe 92 0,00 │ callq debug\_locks\_off 0,00 │ test %eax,%eax 0,00 │ ↓ je 92 0,00 │ cmpl $0x0,0x4c9ff3(%rip) # ffffffff81aacb80 <debug\_locks\_silent> 0,00 │ ↓ jne 92 0,00 │ mov $0xbfd,%esi 0,00 │ mov $0xffffffff818039ac,%rdi 0,00 │ callq warn\_slowpath\_null The currently algorithm illustrated in the image use a simple heuritic to show jumps that points to before the cursor....

May 1, 2012 · 2 min · Hagen Paul Pfeifer

Linux Network Emulator Extensions

Seems that the merge window for the upcomming 3.2 close. In davem’s net-next for 3.3 there are a couple of network emulator improvements: rate extension allows to shape the traffic to n bytes/second Currently netem is not in the ability to emulate channel bandwidth. Only static delay (and optional random jitter) can be configured. To emulate the channel rate the token bucket filter (sch_tbf) can be used. But TBF has some major emulation flaws....

January 5, 2012 · 3 min · Hagen Paul Pfeifer

Git Diff Context

Wow, two new git diff options: –minimal to spend extra CPU cycles to generate a shorter diff –function-context to display the whole function that was affected by the change. Nice for reviews by people without the whole context in mind.

December 3, 2011 · 1 min · Hagen Paul Pfeifer

Cisco ASA and DNS Security

I started to inform how Cisco ASA, Cisco PIX and Cisco FWSM firewall appliance secure their domain from DNS traffic. What is possible, what can I transport over DNS without increased drop probability. I question myself what DNS flags can be touched without any flaw. I must admit that I’m no Cisco expert - not at all. If I look at the configuration possibilities I have to say “wow”: class-map inspection_default match default-inspection-traffic policy-map type inspect dns preset_dns_map parameters dns-guard id-randomization message-length maximum 512 id-mismatch count 10 duration 2 action log exit match header-flag RD drop policy-map global_policy class inspection_default inspect dns preset_dns_map service-policy global_policy global What administrator knows DNS at this level?...

November 14, 2011 · 1 min · Hagen Paul Pfeifer

Virtual Processor IDs and TLB

The translation lookaside buffer is a high-speed memory page cache for virtual to physical address translation. It follows the local principle to avoid time consuming lookups for recently used pages. But what happened in a virtual environment (e.g. kvm, xen, vmware)? Host mappings are not coherent to the guest and vice versa. Each guest has it’s own address space, the mapping table cannot be re-used in another guest (or host). Therefore first generation VMs like Intel Core 2 (VMX) flush the TLB on each vm-enter (resume) and vm-exit....

November 13, 2011 · 2 min · Hagen Paul Pfeifer

Ccontrol and Specific Make Environments

Davem wrote that he sometimes accidentally type make -j 128 on his Intel platform (btw: davem is Sparc maintainer). Rusty wrote that this was the main purpose to write ccontrol. A wrapper to control distcc, ccache and make. Via ccontrol you can configure the current setup for the local machine. After that you use ccontrol instead of make and ccontrol will use the configured setting for this environment. A standard configuration, generated via ccontrol-init on a Dual Core Processor looks like the following (~/....

November 12, 2011 · 1 min · Hagen Paul Pfeifer

UEFI Secure Booting

Matthew Garrett blogged one more time about UEFI isses. To cite the most criticial problem: “This is a little awkward for a couple of reasons. First, it means that any updates to the bootloader would require the user to manually accept the binary again. Second, as we’ve seen with https, there’s the risk of uesrs just blindly accepting things. If it’s acceptable to do this off internal media[5] then malware could just rely on some number of users saying “yes”....

October 20, 2011 · 1 min · Hagen Paul Pfeifer

ELF Symbol Name Length

Category: unlimited. The ELF spec has no real (artificial) symbol name limitation. It only restricts offsets in string table by 4 bytes. And gcc/gdb are consequent: they also introduce no artificial limitation. Of course, resolving dynamic linked object requires hashing and strcmp’ing these symbol names. Especially larger projects with lots of symbols will suffer from this (you may notice this for C++ symbols because of namespace bloat).

October 20, 2011 · 1 min · Hagen Paul Pfeifer