Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  trusty_peer_id.h

  Sprache: C
 

/*
 * Copyright (c) 2025 Google Inc. All rights reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files
 * (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#pragma once

#include <assert.h>
#include <stdint.h>
#include <uapi/trusty_uuid.h>

typedef uint64_t trusty_peer_id_kind_t;

/**
 * enum - Discriminant for trusty_peer_id kinds
 */

enum : trusty_peer_id_kind_t {
    /**
     * @TRUSTY_PEER_ID_KIND_INVALID: Indicates an invalid peer ID. The ID data
     * should be zeroed.
     */

    TRUSTY_PEER_ID_KIND_INVALID = 0x0,

    /**
     * @TRUSTY_PEER_ID_KIND_UUID: Indicates a peer identified by a uuid. The
     * peer is a local TA.
     */

    TRUSTY_PEER_ID_KIND_UUID = 0x1,

    /**
     * @TRUSTY_PEER_ID_KIND_VMID_FFA: Indicates a peer running on an FF-A
     * partition VM, identified by a vmid. Primarily used internally by the
     * authmgr protocol. In legitimate settings, only the authmgr-fe in the
     * remote pVM should connect this way.
     */

    TRUSTY_PEER_ID_KIND_VMID_FFA = 0x2,

    /**
     * @TRUSTY_PEER_ID_KIND_FIRST_USERSPACE_AVAILABLE: Peer ID kind values less
     * than this value are reserved for kernel use.
     */

    TRUSTY_PEER_ID_KIND_FIRST_USERSPACE_AVAILABLE = 0x10000,
};

/**
 * struct trusty_peer_id - DST that contains any type of peer identifier.
 *
 * @kind: The type of peer identifier stored in @data.
 * @data: Byte array containing the identifier specified by @kind.
 */

struct trusty_peer_id {
    trusty_peer_id_kind_t kind;
    char data[];
};

/**
 * struct trusty_peer_id_storage - Sized type that has space to contain any peer
 * identifier defined by the kernel.
 *
 * @kind: The type of peer identifier stored in @data.
 * @data: Byte array containing the identifier specified by @kind. Any unused
 *        bytes should be zero.
 */

struct trusty_peer_id_storage {
    trusty_peer_id_kind_t kind;
    char data[16];
};

#define TRUSTY_PEER_ID_STORAGE_INITIAL_VALUE() \
    {.kind = TRUSTY_PEER_ID_KIND_INVALID, .data = {0}}

/**
 * struct trusty_peer_id_uuid - trusty_peer_id type for peers identified by uuid
 *
 * @kind: Set to TRUSTY_PEER_ID_KIND_UUID.
 * @id:   The peer's uuid.
 */

struct trusty_peer_id_uuid {
    trusty_peer_id_kind_t kind;
    uuid_t id;
};

#define TRUSTY_PEER_ID_UUID_VALUE(uuid_value) \
    {.kind = TRUSTY_PEER_ID_KIND_UUID, .id = uuid_value}

static_assert(sizeof(struct trusty_peer_id_storage) >=
                      sizeof(struct trusty_peer_id_uuid),
              "trusty_peer_id_uuid must fit inside trusty_peer_id_storage.");
static_assert(sizeof(struct trusty_peer_id_uuid) ==
                      sizeof(struct trusty_peer_id) +
                              sizeof((struct trusty_peer_id_uuid){}.id),
              "trusty_peer_id_uuid must not have implicit padding.");

/**
 * struct trusty_peer_id_vmid_ffa - trusty_peer_id type for peers identified by
 * an FF-A VM ID.
 *
 * @kind:       Set to TRUSTY_PEER_ID_KIND_VMID_FFA.
 * @reserved_1: Set to 1. Reserved for future use.
 * @id:         The peer ID for the peer VM. Will be within [0..u16::MAX].
 * @padding:    Explicit padding so this struct's size doesn't change between 32
 *              and 64-bit builds, e.g. 32-bit userspace with 64-bit kernel.
 *              Zeroed.
 */

struct trusty_peer_id_vmid_ffa {
    trusty_peer_id_kind_t kind;
    uint64_t reserved_1;
    uint16_t id;
    uint8_t padding[6];
};

#define TRUSTY_PEER_ID_VMID_FFA_VALUE(vmid_value) \
    {.kind = TRUSTY_PEER_ID_KIND_VMID_FFA,        \
     .reserved_1 = 1,                             \
     .id = vmid_value,                            \
     .padding = {0}}

static_assert(
        sizeof(struct trusty_peer_id_storage) >=
                sizeof(struct trusty_peer_id_vmid_ffa),
        "trusty_peer_id_vmid_ffa must fit inside trusty_peer_id_storage.");
static_assert(
        sizeof(struct trusty_peer_id_vmid_ffa) ==
                sizeof(struct trusty_peer_id) +
                        sizeof((struct trusty_peer_id_vmid_ffa){}.reserved_1) +
                        sizeof((struct trusty_peer_id_vmid_ffa){}.id) +
                        sizeof((struct trusty_peer_id_vmid_ffa){}.padding),
        "trusty_peer_id_vmid_ffa must not have implicit padding.");

/**
 * struct trusty_peer_id_sized - &struct trusty_peer_id
 * including the size of the kind and payload.
 *
 * @size: Size in bytes of @peer_id (excluding @size).
 * @peer_id: The peer ID of type &struct trusty_peer_id.
 */

struct trusty_peer_id_sized {
    uint64_t size;
    struct trusty_peer_id peer_id;
};

/**
 * struct trusty_peer_id_uuid_sized - &struct trusty_peer_id_uuid
 * including the size of the kind and payload.
 *
 * @size: Size in bytes of @peer_id (excluding @size).
 * @peer_id: The peer ID of type &struct trusty_peer_id_uuid.
 */

struct trusty_peer_id_uuid_sized {
    uint64_t size;
    struct trusty_peer_id_uuid peer_id;
};

/**
 * struct trusty_peer_id_vmid_ffa_sized - &struct trusty_peer_id_vmid_ffa
 * including the size of the kind and payload.
 *
 * @size: Size in bytes of @peer_id (excluding @size).
 * @peer_id: The peer ID of type &struct trusty_peer_id_vmid_ffa.
 */

struct trusty_peer_id_vmid_ffa_sized {
    uint64_t size;
    struct trusty_peer_id_vmid_ffa peer_id;
};

static_assert(sizeof(struct trusty_peer_id_sized) ==
                      sizeof(struct trusty_peer_id) +
                              sizeof((struct trusty_peer_id_sized){}.size),
              "trusty_peer_id_sized must not have implicit padding.");
static_assert(sizeof(struct trusty_peer_id_uuid_sized) ==
                      sizeof(struct trusty_peer_id_uuid) +
                              sizeof((struct trusty_peer_id_uuid_sized){}.size),
              "trusty_peer_id_uuid_sized must not have implicit padding.");
static_assert(
        sizeof(struct trusty_peer_id_vmid_ffa_sized) ==
                sizeof(struct trusty_peer_id_vmid_ffa) +
                        sizeof((struct trusty_peer_id_vmid_ffa_sized){}.size),
        "trusty_peer_id_vmid_ffa_sized must not have implicit padding.");

/**
 * trusty_peer_id_storage_to_trusty_peer_id() - Casts a
 * `struct trusty_peer_id_storage` into a `struct trusty_peer_id`.
 *
 * @peer_id: The `struct trusty_peer_id_storage` to cast.
 */

static inline struct trusty_peer_id* trusty_peer_id_storage_to_trusty_peer_id(
        struct trusty_peer_id_storage* peer_id) {
    return (struct trusty_peer_id*)peer_id;
}

/**
 * trusty_peer_id_uuid_to_trusty_peer_id() - Casts a
 * `struct trusty_peer_id_uuid` into a `struct trusty_peer_id`.
 *
 * @peer_id: The `struct trusty_peer_id_uuid` to cast.
 */

static inline struct trusty_peer_id* trusty_peer_id_uuid_to_trusty_peer_id(
        struct trusty_peer_id_uuid* peer_id) {
    return (struct trusty_peer_id*)peer_id;
}

/**
 * trusty_peer_id_to_trusty_peer_id_uuid() - Casts a
 * `struct trusty_peer_id` into a `struct trusty_peer_id_uuid`.
 *
 * @peer_id: The `struct trusty_peer_id` to cast. The caller must ensure
 * that the kind is `TRUSTY_PEER_ID_KIND_UUID` before calling this function.
 */

static inline struct trusty_peer_id_uuid* trusty_peer_id_to_trusty_peer_id_uuid(
        const struct trusty_peer_id* peer_id) {
    assert(peer_id->kind == TRUSTY_PEER_ID_KIND_UUID);
    return (struct trusty_peer_id_uuid*)peer_id;
}

Messung V0.5 in Prozent
C=92 H=93 G=92

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik