Skip to contentSkip to conversation

pte_val(*pte) as lvalue

DISCUSSION Andi Kleen 4 participants 6 messages Jul 2, 2001 – Jul 3, 2001 1 message not in the archive

lore
Share & tools
lore
#2 lore raw

** Reply to message from Andi Kleen <[email protected]> on 03 Jul 2001 01:33:42 +0200

Quoted 7 lines
Quoted 3 lines · Timur Tabi

What is the accepted way to assign an integer to a pte that works in 2.2 and 2.4?

set_pte(pte, mk_pte( ... ))

I'm not sure how to use mk_pte. The first parameter is a struct page *, which I don't have. All I'm doing is modifying the PTE value. I don't want to "make" another one.

Signature · 2 lines
Timur Tabi - [email protected]
Interactive Silicon - http://www.interactivesi.com
#3 lore raw
In reply to a message not in the archive
Quoted 6 lines · Timur Tabi

** Reply to message from Andi Kleen <[email protected]> on 03 Jul 2001 01:33:42 +0200

Quoted 1 line

set_pte(pte, mk_pte( ... ))

I'm not sure how to use mk_pte. The first parameter is a struct page *, which I don't have. All I'm doing is modifying the PTE value. I don't want to "make" another one.

set_pte is the only way you can guarantee that the architecture implementation gets to do what it needs to do with the PTE value before stuffing it into the PTE tables.

Can I ask what the nature of the PTE modification is, and where you are making this modification?

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html

#4 lore raw
In reply to a message not in the archive
Quoted 3 lines · Russell King

Can I ask what the nature of the PTE modification is, and where you are making this modification?

I've written a hack which enables PAT (Page Address Translation) for a particular page:

void set_pte_pat(pte_t *pte, unsigned long pat_index) {
unsigned long p = pte_val(*pte);

p &= ~(_PAGE_PROTNONE | _PAGE_PCD | _PAGE_PWT); // zero-out the
relevant bits

   if (pat_index & 4)
   p |= _PAGE_PROTNONE;

   if (pat_index & 2)
   p |= _PAGE_PCD;

   if (pat_index & 1)
   p |= _PAGE_PWT;

#if CONFIG_X86_PAE
pte->pte_high = 0;
pte->pte_low = p;
#else
pte_val(*pte) = p;
#endif

Signature · 2 lines
Timur Tabi
Interactive Silicon
#5 lore raw
In reply to a message not in the archive
Quoted 6 lines · Timur Tabi
Quoted 3 lines · Russell King

Can I ask what the nature of the PTE modification is, and where you are making this modification?

I've written a hack which enables PAT (Page Address Translation) for a particular page:

Firstly, I'll say I'm no x86 expert by any means. However, it may be better to extend the pte bit handling functions in include/asm-i386/pgtable.h to include the bits you need to handle. (eg, see how pte_mkwrite and pte_wrprotect are implemented.) This is probably the cleanest way of handling these bits.

--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html