Skip to contentSkip to conversation

Use of TARGET_FMT_plx in hw/tpm/trace-events

Qemu-devel Markus Armbruster 3 participants 5 messages Jul 20, 2019 – Jul 22, 2019

lore
Share & tools
lore
#0 lore raw

Consider hw/tpm/trace-events

    # tpm_crb.c
    tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
    tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32

Format is TARGET_FMT_plx formats a hwaddr, but the parameter type is uint64_t. They happen to be the same. Is this kosher?

#1 lore raw
Quoted 9 lines · Markus Armbruster

Consider hw/tpm/trace-events

    # tpm_crb.c
    tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
    tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32

Format is TARGET_FMT_plx formats a hwaddr, but the parameter type is uint64_t. They happen to be the same. Is this kosher?

Missed when converting from DPRINTF() to trace-events:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=ec427498;hp=8cb340c613

PRIx64 certainly makes sense here.

Since it is the single use, once updated we can remote this hunk from scripts/tracetool/format/log_stap.py:

    if macro == "TARGET_FMT_plx":
        return "%016x"

I guess remember a thread with Thomas talking about TARGET_FMT_plx but I can't find it, maybe I dreamed about it...

The idea was, we poison TARGET_FMT_l[udx] but not TARGET_FMT_plx, we could, but then we have to fix few formats, once done TARGET_FMT_plx existence is almost irrelevant.

#2 lore raw
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Markus Armbruster

Consider hw/tpm/trace-events

    # tpm_crb.c
    tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
    tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32

Format is TARGET_FMT_plx formats a hwaddr, but the parameter type is uint64_t. They happen to be the same. Is this kosher?

Missed when converting from DPRINTF() to trace-events:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=ec427498;hp=8cb340c613

PRIx64 certainly makes sense here.

Quoted 8 lines

Since it is the single use, once updated we can remote this hunk from scripts/tracetool/format/log_stap.py:

    if macro == "TARGET_FMT_plx":
        return "%016x"

I guess remember a thread with Thomas talking about TARGET_FMT_plx but I can't find it, maybe I dreamed about it...

That was:

https://patchwork.kernel.org/patch/10930327/

... I think we should rename it to HWADDR_PRI0x or so.

Thomas

#3 lore raw
Quoted 23 lines · Thomas Huth
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Markus Armbruster

Consider hw/tpm/trace-events

    # tpm_crb.c
    tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
    tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32

Format is TARGET_FMT_plx formats a hwaddr, but the parameter type is uint64_t. They happen to be the same. Is this kosher?

Missed when converting from DPRINTF() to trace-events:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=ec427498;hp=8cb340c613

PRIx64 certainly makes sense here.

Since it is the single use, once updated we can remote this hunk from scripts/tracetool/format/log_stap.py:

    if macro == "TARGET_FMT_plx":
        return "%016x"
Quoted 8 lines
Quoted 2 lines

I guess remember a thread with Thomas talking about TARGET_FMT_plx but I can't find it, maybe I dreamed about it...

That was:

https://patchwork.kernel.org/patch/10930327/

... I think we should rename it to HWADDR_PRI0x or so.

I'd expect "PRI" macros to expand into just a format specifier. "%016" PRIx64 is a full conversion specification. Something like HWADDR_FMT0x would work for me.

"Use HWADDR_PRIx and slowly kill TARGET_FMT_plx" (suggested in the thread you linked) would also work for me.

#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Markus Armbruster

Consider hw/tpm/trace-events

    # tpm_crb.c
    tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
    tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32

Format is TARGET_FMT_plx formats a hwaddr, but the parameter type is uint64_t. They happen to be the same. Is this kosher?

Missed when converting from DPRINTF() to trace-events:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=ec427498;hp=8cb340c613

Quoted 7 lines

PRIx64 certainly makes sense here.

Since it is the single use, once updated we can remote this hunk from scripts/tracetool/format/log_stap.py:

    if macro == "TARGET_FMT_plx":
        return "%016x"

Good point, thanks!

[...]