diff options
| author | Thomas Zimmermann <[email protected]> | 2023-10-11 09:50:59 +0200 | 
|---|---|---|
| committer | Thomas Zimmermann <[email protected]> | 2023-10-11 09:50:59 +0200 | 
| commit | 57390019b68b83f96eb98f490367b9df1f2d77cb (patch) | |
| tree | e6d4b6c75efdd2d7fb7d37f980688c491be3ff6a /tools/testing/selftests/kvm/lib/ucall_common.c | |
| parent | e5f9d543419c78ac58f3b3557bc5a76b20ff600b (diff) | |
| parent | 389af786f92ecdff35883551d54bf4e507ffcccb (diff) | |
Merge drm/drm-next into drm-misc-next
Updating drm-misc-next to the state of Linux v6.6-rc2.
Signed-off-by: Thomas Zimmermann <[email protected]>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/ucall_common.c')
| -rw-r--r-- | tools/testing/selftests/kvm/lib/ucall_common.c | 44 | 
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/ucall_common.c b/tools/testing/selftests/kvm/lib/ucall_common.c index 2f0e2ea941cc..816a3fa109bf 100644 --- a/tools/testing/selftests/kvm/lib/ucall_common.c +++ b/tools/testing/selftests/kvm/lib/ucall_common.c @@ -11,6 +11,11 @@ struct ucall_header {  	struct ucall ucalls[KVM_MAX_VCPUS];  }; +int ucall_nr_pages_required(uint64_t page_size) +{ +	return align_up(sizeof(struct ucall_header), page_size) / page_size; +} +  /*   * ucall_pool holds per-VM values (global data is duplicated by each VM), it   * must not be accessed from host code. @@ -70,6 +75,45 @@ static void ucall_free(struct ucall *uc)  	clear_bit(uc - ucall_pool->ucalls, ucall_pool->in_use);  } +void ucall_assert(uint64_t cmd, const char *exp, const char *file, +		  unsigned int line, const char *fmt, ...) +{ +	struct ucall *uc; +	va_list va; + +	uc = ucall_alloc(); +	uc->cmd = cmd; + +	WRITE_ONCE(uc->args[GUEST_ERROR_STRING], (uint64_t)(exp)); +	WRITE_ONCE(uc->args[GUEST_FILE], (uint64_t)(file)); +	WRITE_ONCE(uc->args[GUEST_LINE], line); + +	va_start(va, fmt); +	guest_vsnprintf(uc->buffer, UCALL_BUFFER_LEN, fmt, va); +	va_end(va); + +	ucall_arch_do_ucall((vm_vaddr_t)uc->hva); + +	ucall_free(uc); +} + +void ucall_fmt(uint64_t cmd, const char *fmt, ...) +{ +	struct ucall *uc; +	va_list va; + +	uc = ucall_alloc(); +	uc->cmd = cmd; + +	va_start(va, fmt); +	guest_vsnprintf(uc->buffer, UCALL_BUFFER_LEN, fmt, va); +	va_end(va); + +	ucall_arch_do_ucall((vm_vaddr_t)uc->hva); + +	ucall_free(uc); +} +  void ucall(uint64_t cmd, int nargs, ...)  {  	struct ucall *uc;  |