mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-02 05:34:04 +00:00
sbuf_put copies sbuf->ele_size of data, and puts into ring. Currently this function assumes that data size from caller is no less than sbuf->ele_size. But as sbuf->ele_size is usually setup by some sources outside of the HV (e.g., the service VM), it is not meant to be trusted. So caller should provide the max length of the data for safety reason. sbuf_put() will return UINT32_MAX if max_len of data is less than element size. Additionally, a helper function sbuf_put_many() is added for putting multiple entries. Tracked-On: #8547 Signed-off-by: Wu Zhou <wu.zhou@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
28 lines
786 B
C
28 lines
786 B
C
/*
|
|
* SHARED BUFFER
|
|
*
|
|
* Copyright (C) 2017-2022 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*
|
|
* Li Fei <fei1.li@intel.com>
|
|
*
|
|
*/
|
|
|
|
#ifndef SHARED_BUFFER_H
|
|
#define SHARED_BUFFER_H
|
|
#include <acrn_common.h>
|
|
#include <asm/guest/vm.h>
|
|
/**
|
|
*@pre sbuf != NULL
|
|
*@pre data != NULL
|
|
*/
|
|
uint32_t sbuf_put(struct shared_buf *sbuf, uint8_t *data, uint32_t max_len);
|
|
uint32_t sbuf_put_many(struct shared_buf *sbuf, uint32_t elem_size, uint8_t *data, uint32_t data_size);
|
|
int32_t sbuf_share_setup(uint16_t cpu_id, uint32_t sbuf_id, uint64_t *hva);
|
|
void sbuf_reset(void);
|
|
uint32_t sbuf_next_ptr(uint32_t pos, uint32_t span, uint32_t scope);
|
|
int32_t sbuf_setup_common(__unused struct acrn_vm *vm, uint16_t cpu_id, uint32_t sbuf_id, uint64_t *hva);
|
|
|
|
#endif /* SHARED_BUFFER_H */
|