[PATCHv3 3/6] Crashdump-Accepting-Active-IOMMU-Domain-Interfaces

Sumner, William bill.sumner at hp.com
Mon Mar 10 15:23:11 EDT 2014


On Tue 3/4/2014 8:59 AM, Joerg Roedel wrote
>On Fri, Jan 10, 2014 at 03:07:29PM -0700, Bill Sumner wrote:
>> +context_get_entry(struct context_entry *context_addr,
>> +			struct intel_iommu *iommu, u32 bus, int devfn) {
>> +	unsigned long long q;		/* quadword scratch */
>> +	struct root_entry *root_phys;	/* Phys adr (root table entry) */
>> +	struct root_entry  root_temp;	/* Local copy of root_entry */
>> +	struct context_entry *context_phys;	/* Phys adr */
>> +
>> +	if (pr_dbg.domain_get)
>> +		pr_debug("ENTER %s B:D:F=%2.2x:%2.2x:%1.1x &context_entry:0x%llx &intel_iommu:0x%llx\n",
>> +			__func__, bus, devfn>>3, devfn&7,
>> +			(u64)context_addr, (u64)iommu);
>> +
>> +	if (bus > 255)				/* Sanity check */
>> +		return -5;
>> +	if (devfn > 255 || devfn < 0)		/* Sanity check */
>> +		return -6;
>> +
>> +	q = readq(iommu->reg + DMAR_RTADDR_REG);
>> +	pr_debug("IOMMU %d: DMAR_RTADDR_REG:0x%16.16llx\n", iommu->seq_id, q);
>> +	if (!q)
>> +		return -1;
>> +
>> +	root_phys = (struct root_entry *) q;	/* Adr(base of vector) */
>> +	root_phys += bus;			/* Adr(entry we want) */
>> +
>> +	oldcopy(&root_temp, root_phys, sizeof(root_temp));
>> +
>> +	pr_debug("root_temp.val:0x%llx .rsvd1:0x%llx root_phys:0x%llx\n",
>> +		root_temp.val, root_temp.rsvd1, (u64)root_phys);
>> +
>> +	if (!root_present(&root_temp))
>> +		return -2;
>> +
>> +	pr_debug("B:D:F=%2.2x:%2.2x:%1.1x root_temp.val: %llx .rsvd1: %llx\n",
>> +		bus, devfn >> 3, devfn & 7, root_temp.val, root_temp.rsvd1);
>> +
>> +	if (root_temp.rsvd1)			/* If (root_entry is bad) */
>> +		return -3;
>> +
>> +	context_phys = get_context_phys_from_root(&root_temp);
>> +	if (!context_phys)
>> +		return -4;
>
>What do all these magic return values mean? 

They all mean "No value to return".  The different negative values are an artifact of the development where I wanted to make it easy not only to tell that something went wrong, but also to have enough detail to figure-out what happened without having to add code and repeat the test.  I will clean-up these in the next submission -- along with a few additional places where there are similar "leftovers".  

Bill





More information about the kexec mailing list