Skip to contentSkip to conversation

unaligned access?

Linux-ia64 Pereira, D LailaX E 4 participants 6 messages Nov 28, 2001

lore
Share & tools
lore
#0 lore raw

HI
While running the following code,

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

....
if (WRITE_CAUSED_SIGBUS_or_SEGV){
........
}
else {
.........
}

I get the following error on the "if " statement:
stress.udp(31438): unaligned access to
0x4000000000003541,ip=0x4000000000015fc1
Please let me know what is wrong with the macro:

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

thanks
d'laila

#1 lore raw
Quoted 12 lines · D LailaX E

HI
While running the following code,

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

....
if (WRITE_CAUSED_SIGBUS_or_SEGV){
........
}
else {
.........
}

Quoted 6 lines

I get the following error on the "if " statement:
stress.udp(31438): unaligned access to
0x4000000000003541,ip=0x4000000000015fc1
Please let me know what is wrong with the macro:

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

scp->sc_ip is not properly aligned for an unsigned long access, i.e. it is not a multiple of 8.

Dan

#2 lore raw
In reply to Pereira, D LailaX E

scp->sc_ip is not properly aligned for an unsigned long access, i.e. it is not a multiple of 8.

Dan
But ,
sc_ip field is defined as "unsigned long" in

struct sigcontext {
	...
	unsigned long sc_ip;
	...
}

??

d'laila

Quoted 18 lines · D LailaX E

HI
While running the following code,

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

....
if (WRITE_CAUSED_SIGBUS_or_SEGV){
........
}
else {
.........
}

I get the following error on the "if " statement:
stress.udp(31438): unaligned access to
0x4000000000003541,ip=0x4000000000015fc1
Please let me know what is wrong with the macro:

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)
#3 lore raw
In reply to Pereira, D LailaX E

D'Laila-

Some basic IA64'isms:

The instruction pointer points to a bundle that includes 3 instructions. All instruction bundles are alligned on a 16-byte boundary.

The instruction pointer as reported by a signal trap frame encodes both the bundle address and the specific instruction inside the bundle that caused the fault. The specific instruction is encoded in the lowest 4 bits of the bundle address. In your situatation, the bundle address was at 0x4000000000003540 and the second instruction (encoded as 1) in the bundle was the one that caused the fault.

Just anding off the lower 4 bits from `scp->sc_ip' will solve your problem.

Quoted 30 lines · D LailaX E

HI
While running the following code,

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

....
if (WRITE_CAUSED_SIGBUS_or_SEGV){
........
}
else {
.........
}

I get the following error on the "if " statement:
stress.udp(31438): unaligned access to
0x4000000000003541,ip=0x4000000000015fc1
Please let me know what is wrong with the macro:

define WRITE_CAUSED_SIGBUS_or_SEGV \
        (((*(unsigned long*)scp->sc_ip)>>21)&1)

thanks
d'laila

_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64

Signature · 4 lines
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
[email protected]
Ph: 303/652-0870x117
#4 lore raw
In reply to Pereira, D LailaX E
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · D LailaX E

HI While running the following code, define WRITE_CAUSED_SIGBUS_or_SEGV \ (((*(unsigned long*)scp->sc_ip)>>21)&1) .... if (WRITE_CAUSED_SIGBUS_or_SEGV){ ........ } else { ......... }

Quoted 5 lines
Quoted 5 lines

I get the following error on the "if " statement:
stress.udp(31438): unaligned access to 0x4000000000003541,ip=0x4000000000015fc1 Please let me know what is wrong with the macro: define WRITE_CAUSED_SIGBUS_or_SEGV \
(((*(unsigned long*)scp->sc_ip)>>21)&1)

The least significant two bits of sc_ip encode the slot number. You need to take those bits into account when reading an instruction from a bundle.

	--david
#5 lore raw
In reply to Pereira, D LailaX E
Quoted 7 lines · D LailaX E

scp->sc_ip is not properly aligned for an unsigned long access, i.e. it is not a multiple of 8.

Dan
But ,
sc_ip field is defined as "unsigned long" in

Quoted 7 lines
struct sigcontext {
	...
	unsigned long sc_ip;
	...
}

??

The problem is not how it is defined, but what value it contains. In your case, its value was not a multiple of 8, hence your problem.

Other people have already explained how to properly use its value to get the relevant bundle address (clear the least significant 4 bits). Do the proper masking in your macro and you should get the expected results.

Dan