Skip to content

Commit 621b7e5

Browse files
nuttyliujoergroedel
authored andcommitted
iommu/vt-d: Remove private data use in fault message
According to Intel VT-d specification revision 4.0, "Private Data" field has been removed from Page Request/Response. Since the private data field is not used in fault message, remove the related definitions in page request descriptor and remove the related code in page request/response handler, as Intel hasn't shipped any products which support private data in the page request message. Signed-off-by: Jingqi Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent cc9e49d commit 621b7e5

File tree

3 files changed

+16
-63
lines changed

3 files changed

+16
-63
lines changed

drivers/iommu/intel/iommu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ enum {
455455

456456
/* Page group response descriptor QW0 */
457457
#define QI_PGRP_PASID_P(p) (((u64)(p)) << 4)
458-
#define QI_PGRP_PDP(p) (((u64)(p)) << 5)
459458
#define QI_PGRP_RESP_CODE(res) (((u64)(res)) << 12)
460459
#define QI_PGRP_DID(rid) (((u64)(rid)) << 16)
461460
#define QI_PGRP_PASID(pasid) (((u64)(pasid)) << 32)

drivers/iommu/intel/svm.c

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ struct page_req_dsc {
418418
struct {
419419
u64 type:8;
420420
u64 pasid_present:1;
421-
u64 priv_data_present:1;
422-
u64 rsvd:6;
421+
u64 rsvd:7;
423422
u64 rid:16;
424423
u64 pasid:20;
425424
u64 exe_req:1;
@@ -438,7 +437,8 @@ struct page_req_dsc {
438437
};
439438
u64 qw_1;
440439
};
441-
u64 priv_data[2];
440+
u64 qw_2;
441+
u64 qw_3;
442442
};
443443

444444
static bool is_canonical_address(u64 addr)
@@ -572,58 +572,30 @@ static void intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
572572
event.fault.prm.flags |= IOMMU_FAULT_PAGE_REQUEST_PASID_VALID;
573573
event.fault.prm.flags |= IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID;
574574
}
575-
if (desc->priv_data_present) {
576-
/*
577-
* Set last page in group bit if private data is present,
578-
* page response is required as it does for LPIG.
579-
* iommu_report_device_fault() doesn't understand this vendor
580-
* specific requirement thus we set last_page as a workaround.
581-
*/
582-
event.fault.prm.flags |= IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
583-
event.fault.prm.flags |= IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA;
584-
event.fault.prm.private_data[0] = desc->priv_data[0];
585-
event.fault.prm.private_data[1] = desc->priv_data[1];
586-
}
587575

588576
iommu_report_device_fault(dev, &event);
589577
}
590578

591579
static void handle_bad_prq_event(struct intel_iommu *iommu,
592580
struct page_req_dsc *req, int result)
593581
{
594-
struct qi_desc desc;
582+
struct qi_desc desc = { };
595583

596584
pr_err("%s: Invalid page request: %08llx %08llx\n",
597585
iommu->name, ((unsigned long long *)req)[0],
598586
((unsigned long long *)req)[1]);
599587

600-
/*
601-
* Per VT-d spec. v3.0 ch7.7, system software must
602-
* respond with page group response if private data
603-
* is present (PDP) or last page in group (LPIG) bit
604-
* is set. This is an additional VT-d feature beyond
605-
* PCI ATS spec.
606-
*/
607-
if (!req->lpig && !req->priv_data_present)
588+
if (!req->lpig)
608589
return;
609590

610591
desc.qw0 = QI_PGRP_PASID(req->pasid) |
611592
QI_PGRP_DID(req->rid) |
612593
QI_PGRP_PASID_P(req->pasid_present) |
613-
QI_PGRP_PDP(req->priv_data_present) |
614594
QI_PGRP_RESP_CODE(result) |
615595
QI_PGRP_RESP_TYPE;
616596
desc.qw1 = QI_PGRP_IDX(req->prg_index) |
617597
QI_PGRP_LPIG(req->lpig);
618598

619-
if (req->priv_data_present) {
620-
desc.qw2 = req->priv_data[0];
621-
desc.qw3 = req->priv_data[1];
622-
} else {
623-
desc.qw2 = 0;
624-
desc.qw3 = 0;
625-
}
626-
627599
qi_submit_sync(iommu, &desc, 1, 0);
628600
}
629601

@@ -691,7 +663,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
691663

692664
intel_svm_prq_report(iommu, dev, req);
693665
trace_prq_report(iommu, dev, req->qw_0, req->qw_1,
694-
req->priv_data[0], req->priv_data[1],
666+
req->qw_2, req->qw_3,
695667
iommu->prq_seq_number++);
696668
mutex_unlock(&iommu->iopf_lock);
697669
prq_advance:
@@ -730,42 +702,25 @@ void intel_svm_page_response(struct device *dev, struct iopf_fault *evt,
730702
struct intel_iommu *iommu = info->iommu;
731703
u8 bus = info->bus, devfn = info->devfn;
732704
struct iommu_fault_page_request *prm;
733-
bool private_present;
705+
struct qi_desc desc;
734706
bool pasid_present;
735707
bool last_page;
736708
u16 sid;
737709

738710
prm = &evt->fault.prm;
739711
sid = PCI_DEVID(bus, devfn);
740712
pasid_present = prm->flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID;
741-
private_present = prm->flags & IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA;
742713
last_page = prm->flags & IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
743714

744-
/*
745-
* Per VT-d spec. v3.0 ch7.7, system software must respond
746-
* with page group response if private data is present (PDP)
747-
* or last page in group (LPIG) bit is set. This is an
748-
* additional VT-d requirement beyond PCI ATS spec.
749-
*/
750-
if (last_page || private_present) {
751-
struct qi_desc desc;
752-
753-
desc.qw0 = QI_PGRP_PASID(prm->pasid) | QI_PGRP_DID(sid) |
754-
QI_PGRP_PASID_P(pasid_present) |
755-
QI_PGRP_PDP(private_present) |
756-
QI_PGRP_RESP_CODE(msg->code) |
757-
QI_PGRP_RESP_TYPE;
758-
desc.qw1 = QI_PGRP_IDX(prm->grpid) | QI_PGRP_LPIG(last_page);
759-
desc.qw2 = 0;
760-
desc.qw3 = 0;
761-
762-
if (private_present) {
763-
desc.qw2 = prm->private_data[0];
764-
desc.qw3 = prm->private_data[1];
765-
}
715+
desc.qw0 = QI_PGRP_PASID(prm->pasid) | QI_PGRP_DID(sid) |
716+
QI_PGRP_PASID_P(pasid_present) |
717+
QI_PGRP_RESP_CODE(msg->code) |
718+
QI_PGRP_RESP_TYPE;
719+
desc.qw1 = QI_PGRP_IDX(prm->grpid) | QI_PGRP_LPIG(last_page);
720+
desc.qw2 = 0;
721+
desc.qw3 = 0;
766722

767-
qi_submit_sync(iommu, &desc, 1, 0);
768-
}
723+
qi_submit_sync(iommu, &desc, 1, 0);
769724
}
770725

771726
static void intel_svm_domain_free(struct iommu_domain *domain)

include/linux/iommu.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ enum iommu_fault_type {
6969
struct iommu_fault_page_request {
7070
#define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID (1 << 0)
7171
#define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE (1 << 1)
72-
#define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA (1 << 2)
73-
#define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID (1 << 3)
72+
#define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID (1 << 2)
7473
u32 flags;
7574
u32 pasid;
7675
u32 grpid;

0 commit comments

Comments
 (0)