Skip to contentSkip to conversation

softmmu_header: ldb_kernel vs. ldsb_kernel

Qemu-devel Clemens Kolbitsch 2 participants 3 messages Oct 2, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

hi everyone!
i have a (maybe rather tricky) question:

why do you define 2 different inline load-functions in softmmu_header:

static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr)

vs.

static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr)

??

Obviously this is for signed/unsigned access... but why do you need it? In case there is a TLB miss, both functions call the same function (e.g. __ldl_mmu) --> the return value cannot differ that much.

The only difference I see (that really matters) is how the bytes are copied to the result-pointer (i.e. using movzbl vs. movsbl)... but that's it.

If there is some deeper reason behind that - could you please point that out to me? And if there is such a thing, why is it not necessary for storing (e.g. stb_kernel)??

Thanks!!
Clemens

#2 lore raw
Quoted 11 lines · Clemens Kolbitsch

hi everyone!
i have a (maybe rather tricky) question:

why do you define 2 different inline load-functions in softmmu_header:

static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr)

vs.

static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr)

Quoted 8 lines

??

Obviously this is for signed/unsigned access... but why do you need it? In case there is a TLB miss, both functions call the same function (e.g. __ldl_mmu) --> the return value cannot differ that much.

The only difference I see (that really matters) is how the bytes are copied to the result-pointer (i.e. using movzbl vs. movsbl)... but that's it.

It is a cast. The generic C version for the other architectures makes this more obvious.

Quoted 3 lines

If there is some deeper reason behind that - could you please point that out to me? And if there is such a thing, why is it not necessary for storing (e.g. stb_kernel)??

A load (sign-)extends a value to register size, a store doesn't.

That's why you have e.g. in the MIPS instruction set LB, LBU and SB but no SBU, it would do the same as SB.

Thiemo

#3 lore raw
Quoted 8 lines
Quoted 4 lines

The only difference I see (that really matters) is how the bytes are copied to the result-pointer (i.e. using movzbl vs. movsbl)... but that's it.

It is a cast. The generic C version for the other architectures makes this more obvious.

Quoted 8 lines
Quoted 3 lines

If there is some deeper reason behind that - could you please point that out to me? And if there is such a thing, why is it not necessary for storing (e.g. stb_kernel)??

A load (sign-)extends a value to register size, a store doesn't.

That's why you have e.g. in the MIPS instruction set LB, LBU and SB but no SBU, it would do the same as SB.

all right .. thanks for the fast answer :-)