oss-sec mailing list archives

Re: Intel hyper-threading security issues


From: Seth Arnold <seth.arnold () canonical com>
Date: Fri, 22 Jun 2018 12:26:07 -0700

On Fri, Jun 22, 2018 at 02:08:03PM +1000, Michael Ellerman wrote:
See the script below for example, which shows CPUs grouped by core.

#!/usr/bin/python3

import os
import glob

by_core = {}

for path in glob.iglob('/sys/devices/system/cpu/cpu*/topology/core_id'):
    num = int(path.split('/')[5].replace('cpu', ''))
    core_id = int(open(path).read(), 10)
    by_core.setdefault(core_id, []).append(num)

for core in sorted(by_core.keys()):
    print('%d: %s' % (core, ', '.join([str(s) for s in sorted(by_core[core])])))


Note that this gives misleading results on multi-socket systems:

0: 0, 8, 16, 24
1: 1, 9, 17, 25
2: 2, 10, 18, 26
3: 3, 11, 19, 27
4: 4, 12, 20, 28
5: 5, 13, 21, 29
6: 6, 14, 22, 30
7: 7, 15, 23, 31

This system has two sockets, eight cores per socket, two threads per core.

Solar's cpuinfo reports;
$ ./cpuinfo
Found 32 logical processors across 16 physical cores

Thanks

Attachment: signature.asc
Description:


Current thread: