let set_phys_to_machine return the old entry
PATCH 1/1 let set_phys_to_machine return the old entry
The attached patch makes set_phys_to_machine(pfn,mfn) return the old entry in the array, such that the old entry can be restored again using the same call. If the feature XENFEAT_auto_translate_physmap is not enabled, then these two calls will end up in no-op relative to changes to the phys_to_machine_mapping array.
There's currently only one occurrence where remembering the entry from the array is necessary and this is in the vTPM backend driver.
This patch builds on top of the previously posted TPM backend patch.
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c +1 -2
@@ -297,9 +297,8 @@ int _packet_write(struct packet *pak, pfn =__pa (MMAP_VADDR (tpmif, i)) >>PAGE_SHIFT ; mfn =FOREIGN_FRAME (map_op.dev_bus_addr >>PAGE_SHIFT ); - mfn_orig = phys_to_machine_mapping[pfn]; -set_phys_to_machine (pfn, mfn); + mfn_orig =set_phys_to_machine (pfn, mfn); tocopy =MIN (size - offset,PAGE_SIZE );
xen-unstable.hg/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h +6 -2
@@ -137,13 +137,17 @@ static inline unsigned long mfn_to_localreturn pfn; } -static inline void set_phys_to_machine (unsigned long pfn,unsigned long mfn) +static inline +unsigned long set_phys_to_machine (unsigned long pfn,unsigned long mfn) { +unsigned long mfn_orig;if (xen_feature (XENFEAT_auto_translated_physmap)) {BUG_ON (pfn != mfn && mfn !=INVALID_P2M_ENTRY ); -return ; +return phys_to_machine_mapping[pfn]; } + mfn_orig = phys_to_machine_mapping[pfn]; phys_to_machine_mapping[pfn] = mfn; +return mfn_orig; }/* Definitions for machine and pseudophysical addresses. */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 10 lines · Stefan Berger
The attached patch makes
set_phys_to_machine(pfn,mfn)return the old entry in the array, such that the old entry can be restored again using the same call. If the featureXENFEAT_auto_translate_physmapis not enabled, then these two calls will end up in no-op relative to changes to thephys_to_machine_mappingarray.There's currently only one occurrence where remembering the entry from the array is necessary and this is in the vTPM backend driver.
This patch builds on top of the previously posted TPM backend patch.
Why do you need to mess with the phys_to_machine table at all? You install the mapping only for a very short time, to do a memcpy or copy_from_user: neither of which will use that p2m entry. Even if you really do want to set the p2m entry properly you know that its old value must be INVALID_P2M_ENTRY because you obtained that kernel virtual address via balloon_alloc_empty_page_range().
You should probably just delete the p2m code from that copy routine.
-- Keir
[email protected] wrote on 04/20/2006 03:08:08 PM:
Quoted 5 lines · Stefan Berger
Quoted 3 lines
The attached patch makes
set_phys_to_machine(pfn,mfn)return the old entry in the array, such that the old entry can be restored again
using
Quoted 9 lines
Quoted 8 lines
the same call. If the feature
XENFEAT_auto_translate_physmapis not enabled, then these two calls will end up in no-op relative to changes to thephys_to_machine_mappingarray.There's currently only one occurrence where remembering the entry from the array is necessary and this is in the vTPM backend driver.
This patch builds on top of the previously posted TPM backend patch.
Quoted 8 lines
Why do you need to mess with the
phys_to_machinetable at all? You install the mapping only for a very short time, to do a memcpy orcopy_from_user: neither of which will use that p2m entry. Even if you really do want to set the p2m entry properly you know that its old value must beINVALID_P2M_ENTRYbecause you obtained that kernel virtual address viaballoon_alloc_empty_page_range().You should probably just delete the p2m code from that copy routine.
Going to do that and will repost.
Stefan
Quoted 8 lines
-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel