summaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-06-04 14:42:24 +0200
committerTejun Heo <tj@kernel.org>2017-06-05 15:29:22 -0400
commit818831c8b22f75353f59a63a484e20736c0567c9 (patch)
tree7b76516e71dcaa9a827475017827201a1b35b506 /drivers/ata/libata-core.c
parenta0fd2454a36ffab2ce39b3a91c1385a5f98e63f0 (diff)
downloadtalos-op-linux-818831c8b22f75353f59a63a484e20736c0567c9.tar.gz
talos-op-linux-818831c8b22f75353f59a63a484e20736c0567c9.zip
libata: implement SECURITY PROTOCOL IN/OUT
This allows us to use the generic OPAL code with ATA devices. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 61c97818568c..a846c29f3248 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2405,6 +2405,37 @@ static void ata_dev_config_zac(struct ata_device *dev)
}
}
+static void ata_dev_config_trusted(struct ata_device *dev)
+{
+ struct ata_port *ap = dev->link->ap;
+ u64 trusted_cap;
+ unsigned int err;
+
+ if (!ata_identify_page_supported(dev, ATA_LOG_SECURITY)) {
+ ata_dev_warn(dev,
+ "Security Log not supported\n");
+ return;
+ }
+
+ err = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, ATA_LOG_SECURITY,
+ ap->sector_buf, 1);
+ if (err) {
+ ata_dev_dbg(dev,
+ "failed to read Security Log, Emask 0x%x\n", err);
+ return;
+ }
+
+ trusted_cap = get_unaligned_le64(&ap->sector_buf[40]);
+ if (!(trusted_cap & (1ULL << 63))) {
+ ata_dev_dbg(dev,
+ "Trusted Computing capability qword not valid!\n");
+ return;
+ }
+
+ if (trusted_cap & (1 << 0))
+ dev->flags |= ATA_DFLAG_TRUSTED;
+}
+
/**
* ata_dev_configure - Configure the specified ATA/ATAPI device
* @dev: Target device to configure
@@ -2629,6 +2660,7 @@ int ata_dev_configure(struct ata_device *dev)
}
ata_dev_config_sense_reporting(dev);
ata_dev_config_zac(dev);
+ ata_dev_config_trusted(dev);
dev->cdb_len = 16;
}
OpenPOWER on IntegriCloud