Skip to content

Commit 1d46b3c

Browse files
jamuraaCQ Bot
authored and
CQ Bot
committed
Revert "[tee][devfs] switching to services"
This reverts commit c820680. Reason for revert: breaks build due to `fuchsia.driver.compat.Service` was not offered. Original change's description: > [tee][devfs] switching to services > > Converts the tee drivers and clients to use > services instead of devfs. > > Run-All-Tests: true > > Cq-Include-Trybots: luci.turquoise.global.try:run-postsubmit-tryjobs > > Bug: 324273348 > > Change-Id: I2b3ba970cd5a2e7d6be5dc378a58583c7230e54f > Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1221585 > Reviewed-by: Ali Zhang <[email protected]> > Reviewed-by: Aaron Wood <[email protected]> > Commit-Queue: Garratt Gallagher <[email protected]> Bug: 324273348 Cq-Include-Trybots: luci.turquoise.global.try:run-postsubmit-tryjobs No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I3d1843faeed85800bcbc43ada423f96776848939 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1224704 Commit-Queue: Marie Janssen <[email protected]> Reviewed-by: RubberStamper 🤖 <[email protected]> Reviewed-by: Garratt Gallagher <[email protected]>
1 parent 7e4fdc8 commit 1d46b3c

File tree

17 files changed

+48
-47
lines changed

17 files changed

+48
-47
lines changed

src/devices/bin/driver_manager/devfs/class_names.h

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ const std::unordered_map<std::string_view, ServiceEntry> kClassNameToService = {
121121
{"skip-block",
122122
{ServiceEntry::kDevfsAndService, "fuchsia.hardware.skipblock.Service", "skipblock"}},
123123
{"spi", {ServiceEntry::kDevfsAndService, "fuchsia.hardware.spi.ControllerService", "device"}},
124+
{"tee", {ServiceEntry::kDevfsAndService, "fuchsia.hardware.tee.Service", "device_connector"}},
124125
{"temperature",
125126
{ServiceEntry::kDevfsAndService, "fuchsia.hardware.temperature.Service", "device"}},
126127
{"test", {ServiceEntry::kDevfs, "", ""}},

src/devices/bin/driver_manager/devfs/meta/devfs-driver.cml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"fuchsia.hardware.Serial.ProxyService",
5252
"fuchsia.hardware.skipblock.Service",
5353
"fuchsia.hardware.spi.ControllerService",
54+
"fuchsia.hardware.tee.Service",
5455
"fuchsia.hardware.temperature.Service",
5556
"fuchsia.hardware.thermal.Service",
5657
"fuchsia.hardware.trippoint.TripPointService",
@@ -111,6 +112,7 @@
111112
"fuchsia.hardware.Serial.ProxyService",
112113
"fuchsia.hardware.skipblock.Service",
113114
"fuchsia.hardware.spi.ControllerService",
115+
"fuchsia.hardware.tee.Service",
114116
"fuchsia.hardware.temperature.Service",
115117
"fuchsia.hardware.thermal.Service",
116118
"fuchsia.hardware.trippoint.TripPointService",

src/media/codec/examples/use_media_decoder/meta/decoder_secure_input_output_test.shard.cml

-8
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,10 @@
5656
],
5757
offer: [
5858
{
59-
// TODO(https://fxbug.dev/324273348): Remove this capability once the clients have
60-
// been migrated to services. The service capability has been added below.
6159
directory: "dev-tee",
6260
from: "parent",
6361
to: "#tee_manager",
6462
},
65-
{
66-
// This service replaces the directory capability above.
67-
service: "fuchsia.hardware.tee.Service",
68-
from: "parent",
69-
to: "#tee_manager",
70-
},
7163
{
7264
directory: "config-data",
7365
from: "parent",

src/media/testing/drm_test_realm.shard.cml

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@
6060
rights: [ "r*" ],
6161
},
6262
{
63-
service: "fuchsia.hardware.tee.Service",
63+
directory: "dev-tee",
6464
from: "parent",
6565
to: "#drm-tests",
66+
rights: [ "r*" ],
6667
},
6768
{
6869
directory: "boot",

src/security/bin/tee_manager/meta/optee_smoke_test.cml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
offer: [
2929
{
30-
service: "fuchsia.hardware.tee.Service",
30+
directory: "dev-tee",
3131
from: "parent",
3232
to: "#tee_manager",
3333
},

src/security/bin/tee_manager/meta/optee_test.cml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
offer: [
2929
{
30-
service: "fuchsia.hardware.tee.Service",
30+
directory: "dev-tee",
3131
from: "parent",
3232
to: "#tee_manager",
3333
},

src/security/bin/tee_manager/meta/tee_manager.base.cml

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
{ protocol: "fuchsia.tee.DeviceInfo" },
1515
],
1616
use: [
17-
{ service: "fuchsia.hardware.tee.Service" },
17+
{
18+
directory: "dev-tee",
19+
rights: [ "r*" ],
20+
path: "/dev/class/tee",
21+
},
1822
{
1923
directory: "config-data",
2024
rights: [ "r*" ],

src/security/bin/tee_manager/meta/tee_manager.core_shard.cml

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
],
1717
offer: [
1818
{
19-
service: "fuchsia.hardware.tee.Service",
19+
directory: "dev-class",
2020
from: "parent",
21+
as: "dev-tee",
2122
to: "#tee_manager",
23+
subdir: "tee",
2224
},
2325
{
2426
storage: "data",

src/security/bin/tee_manager/src/main.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use futures::stream::FusedStream;
2222
use std::path::{Path, PathBuf};
2323
use uuid::Uuid;
2424

25-
const DEV_TEE_PATH: &str = "/svc/fuchsia.hardware.tee.Service";
26-
const TEE_SERVICE_MEMBER: &str = "/device_connector";
25+
const DEV_TEE_PATH: &str = "/dev/class/tee";
2726

2827
enum IncomingRequest {
2928
Application(ServerEnd<fuchsia_tee::ApplicationMarker>, fuchsia_tee::Uuid),
@@ -111,9 +110,7 @@ async fn enumerate_tee_devices() -> Result<Vec<PathBuf>, Error> {
111110
if msg.filename == Path::new(".") {
112111
continue;
113112
}
114-
device_list.push(
115-
PathBuf::new().join(DEV_TEE_PATH).join(msg.filename).join(TEE_SERVICE_MEMBER),
116-
);
113+
device_list.push(PathBuf::new().join(DEV_TEE_PATH).join(msg.filename));
117114
}
118115
vfs::WatchEvent::IDLE => {
119116
break;

src/security/lib/kms-stateless/kms-stateless.cc

+5-10
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ namespace kms_stateless {
2626
namespace {
2727

2828
const size_t kDerivedKeySize = 16;
29-
const char kServicePath[] = "/svc/fuchsia.hardware.tee.Service";
30-
const char kServiceMemberName[] = "device_connector";
31-
32-
const size_t kMaxPathLen = 264;
29+
const char kDeviceClass[] = "/dev/class/tee";
30+
// Path estimated to be "/dev/class/tee/XXX".
31+
const size_t kMaxPathLen = 64;
3332

3433
// UUID of the keysafe TA.
3534
const TEEC_UUID kKeysafeTaUuid = TA_KEYSAFE_UUID;
@@ -184,11 +183,7 @@ zx_status_t WatchTee(int dirfd, int event, const char* filename, void* cookie) {
184183
return ZX_OK;
185184
}
186185
fbl::StringBuffer<kMaxPathLen> device_path;
187-
device_path.Append(kServicePath)
188-
.Append("/")
189-
.Append(filename)
190-
.Append("/")
191-
.Append(kServiceMemberName);
186+
device_path.Append(kDeviceClass).Append("/").Append(filename);
192187
// Hardware derived key is expected to be 128-bit AES key.
193188
std::unique_ptr<uint8_t[]> key_buffer(new uint8_t[kDerivedKeySize]);
194189
size_t key_size = 0;
@@ -215,7 +210,7 @@ zx_status_t WatchTee(int dirfd, int event, const char* filename, void* cookie) {
215210

216211
zx_status_t GetHardwareDerivedKey(GetHardwareDerivedKeyCallback callback,
217212
uint8_t key_info[kExpectedKeyInfoSize]) {
218-
zx::result channel = device_watcher::RecursiveWaitForFile(kServicePath, zx::sec(5));
213+
zx::result channel = device_watcher::RecursiveWaitForFile(kDeviceClass, zx::sec(5));
219214
if (channel.is_error()) {
220215
fprintf(stderr, "Error waiting for tee device directory: %s\n", channel.status_string());
221216
return channel.error_value();

src/security/lib/kms-stateless/kms-stateless.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const size_t kExpectedKeyInfoSize = 32;
2121
using GetHardwareDerivedKeyCallback =
2222
fit::function<zx_status_t(std::unique_ptr<uint8_t[]>, size_t)>;
2323

24-
// Get a hardware derived key using the service path.
24+
// Get a hardware derived key using the device /dev/class/tee/000 .
2525
// This is useful in early boot when other services may not be up.
2626
zx_status_t GetHardwareDerivedKey(GetHardwareDerivedKeyCallback callback,
2727
uint8_t key_info[kExpectedKeyInfoSize]);

src/security/lib/kms-stateless/rust/src/lib.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,26 @@ fn rotate_key_from_tee_device(device: Option<&CStr>, info: KeyInfo) -> Result<()
120120
call_command(device, &mut op, TaKeysafeCommand::RotateHardwareDerivedKey)
121121
}
122122

123-
/// Gets a hardware derived key using the first device found in /svc/fuchsia.hardware.tee.Service.
123+
/// Gets a hardware derived key using the first device found in /dev/class/tee.
124124
/// This is useful in early boot when other services may not be up.
125125
pub async fn get_hardware_derived_key(info: KeyInfo) -> Result<Vec<u8>, Error> {
126-
const TEE_SERVICE: &str = "/svc/fuchsia.hardware.tee.Service";
127-
const TEE_SERVICE_MEMBER: &str = "device_connector";
126+
const DEV_CLASS_TEE: &str = "/dev/class/tee";
128127

129-
let dir = fuchsia_fs::directory::open_in_namespace(TEE_SERVICE, fuchsia_fs::Flags::empty())?;
128+
let dir = fuchsia_fs::directory::open_in_namespace(DEV_CLASS_TEE, fuchsia_fs::Flags::empty())?;
130129
let mut stream = device_watcher::watch_for_files(&dir).await?;
131130
let first = stream
132131
.try_next()
133132
.map_err(Error::from)
134133
.on_timeout(std::time::Duration::from_secs(5), || Err(Error::TeeDeviceWaitTimeout))
135134
.await?;
136135
let first = first.ok_or_else(|| {
137-
Error::TeeDeviceWaitFailure(anyhow::anyhow!("'{TEE_SERVICE}' watcher closed unexpectedly"))
136+
Error::TeeDeviceWaitFailure(anyhow::anyhow!(
137+
"'{DEV_CLASS_TEE}' watcher closed unexpectedly"
138+
))
138139
})?;
139140
let first = first.to_str().expect("paths are utf-8");
140141

141-
let dev = format!("{TEE_SERVICE}/{first}/{TEE_SERVICE_MEMBER}");
142+
let dev = format!("{DEV_CLASS_TEE}/{first}");
142143
let dev = CString::new(dev).expect("paths do not contain nul bytes");
143144
get_key_from_tee_device(Some(&dev), info)
144145
}
@@ -149,25 +150,26 @@ pub async fn get_hardware_derived_key_from_service(info: KeyInfo) -> Result<Vec<
149150
get_key_from_tee_device(None, info)
150151
}
151152

152-
/// Rotates the hardware derived key from a tee device at /svc/fuchsia.hardware.tee.Service.
153+
/// Rotates the hardware derived key from a tee device at the /dev/class/tee.
153154
/// This is useful in early boot when other services may not be up.
154155
pub async fn rotate_hardware_derived_key(info: KeyInfo) -> Result<(), Error> {
155-
const TEE_SERVICE: &str = "/svc/fuchsia.hardware.tee.Service";
156-
const TEE_SERVICE_MEMBER: &str = "device_connector";
156+
const DEV_CLASS_TEE: &str = "/dev/class/tee";
157157

158-
let dir = fuchsia_fs::directory::open_in_namespace(TEE_SERVICE, fuchsia_fs::Flags::empty())?;
158+
let dir = fuchsia_fs::directory::open_in_namespace(DEV_CLASS_TEE, fuchsia_fs::Flags::empty())?;
159159
let mut stream = device_watcher::watch_for_files(&dir).await?;
160160
let first = stream
161161
.try_next()
162162
.map_err(Error::from)
163163
.on_timeout(std::time::Duration::from_secs(5), || Err(Error::TeeDeviceWaitTimeout))
164164
.await?;
165165
let first = first.ok_or_else(|| {
166-
Error::TeeDeviceWaitFailure(anyhow::anyhow!("'{TEE_SERVICE}' watcher closed unexpectedly"))
166+
Error::TeeDeviceWaitFailure(anyhow::anyhow!(
167+
"'{DEV_CLASS_TEE}' watcher closed unexpectedly"
168+
))
167169
})?;
168170
let first = first.to_str().expect("paths are utf-8");
169171

170-
let dev = format!("{TEE_SERVICE}/{first}/{TEE_SERVICE_MEMBER}");
172+
let dev = format!("{DEV_CLASS_TEE}/{first}");
171173
let dev = CString::new(dev).expect("paths do not contain nul bytes");
172174
rotate_key_from_tee_device(Some(&dev), info)
173175
}

src/security/lib/tee/tee-client-api/tee-client-api.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ constexpr std::string_view kServiceDirectoryPath("/svc/");
5555

5656
// Presently only used by clients that need to connect before the service is available / don't need
5757
// the TEE to be able to use file services.
58-
constexpr std::string_view kTeeServicePath("/svc/fuchsia.hardware.tee.Service");
58+
constexpr std::string_view kTeeDevClass("/dev/class/tee/");
5959

6060
std::string GetApplicationServicePath(const fuchsia_tee::wire::Uuid& app_uuid) {
6161
constexpr std::string_view kApplicationServicePathPrefix = "/svc/fuchsia.tee.Application.";
@@ -791,7 +791,7 @@ TEEC_Result TEEC_InitializeContext(const char* name, TEEC_Context* context) {
791791
auto name_view = std::string_view(name != nullptr ? name : "");
792792
fidl::ClientEnd<fuchsia_hardware_tee::DeviceConnector> maybe_device_connector;
793793

794-
if (starts_with(name_view, kTeeServicePath)) {
794+
if (starts_with(name_view, kTeeDevClass)) {
795795
if (zx_status_t status = ConnectToDeviceConnector(name, &maybe_device_connector);
796796
status != ZX_OK) {
797797
return TEEC_ERROR_COMMUNICATION;

src/sys/pkg/bin/system-update-configurator/meta/system-update-configurator-integration-test.cml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
to: "#system_update_configurator",
4040
},
4141
{
42-
service: "fuchsia.hardware.tee.Service",
42+
directory: "dev-tee",
4343
from: "parent",
4444
to: "#tee_manager",
4545
},

src/sys/test_manager/meta/test_manager.core_shard.cml

+3-1
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,11 @@
464464
to: "#test_manager",
465465
},
466466
{
467-
service: "fuchsia.hardware.tee.Service",
467+
directory: "dev-class",
468468
from: "parent",
469+
as: "dev-tee",
469470
to: "#test_manager",
471+
subdir: "tee",
470472
},
471473
{
472474
directory: "dev-class",

src/sys/testing/meta/system-tests.shard.cml

+2-1
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,10 @@
322322

323323
// optee_test requires access to /dev/class/tee.
324324
{
325-
service: "fuchsia.hardware.tee.Service",
325+
directory: "dev-tee",
326326
from: "parent",
327327
to: [ "#system-tests" ],
328+
rights: [ "r*" ],
328329
},
329330

330331
// Tests of the media system want to test against the real hardware

src/sys/testing/meta/test_realm.core_shard.cml

+3-1
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,11 @@
488488
to: "#testing",
489489
},
490490
{
491-
service: "fuchsia.hardware.tee.Service",
491+
directory: "dev-class",
492492
from: "parent",
493+
as: "dev-tee",
493494
to: "#testing",
495+
subdir: "tee",
494496
},
495497
{
496498
directory: "dev-class",

0 commit comments

Comments
 (0)