Commit 26a42c25 authored by David Kershner's avatar David Kershner Committed by Greg Kroah-Hartman

staging: unisys: Change data to point to visor_controlvm_parameters_header.

The data field was being defined as a character array and then casted into
a visor_controlvm_parameters_header structure. This patch converts it to
just point to the visor_controlvm_parameters_header structure. The data
following the header is still behind the header_info.
Reported-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarDavid Kershner <david.kershner@unisys.com>
Reviewed-by: default avatarTim Sell <timothy.sell@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent af53ce41
...@@ -53,7 +53,7 @@ struct parser_context { ...@@ -53,7 +53,7 @@ struct parser_context {
u8 *curr; u8 *curr;
unsigned long bytes_remaining; unsigned long bytes_remaining;
bool byte_stream; bool byte_stream;
char data[0]; struct visor_controlvm_parameters_header data;
}; };
/* VMCALL_CONTROLVM_ADDR: Used by all guests, not just IO. */ /* VMCALL_CONTROLVM_ADDR: Used by all guests, not just IO. */
...@@ -299,10 +299,7 @@ static DEVICE_ATTR_RW(remaining_steps); ...@@ -299,10 +299,7 @@ static DEVICE_ATTR_RW(remaining_steps);
static const guid_t *parser_id_get(struct parser_context *ctx) static const guid_t *parser_id_get(struct parser_context *ctx)
{ {
struct visor_controlvm_parameters_header *phdr = NULL; return &ctx->data.id;
phdr = (struct visor_controlvm_parameters_header *)(ctx->data);
return &phdr->id;
} }
static void parser_done(struct parser_context *ctx) static void parser_done(struct parser_context *ctx)
...@@ -348,12 +345,12 @@ static void *parser_name_get(struct parser_context *ctx) ...@@ -348,12 +345,12 @@ static void *parser_name_get(struct parser_context *ctx)
{ {
struct visor_controlvm_parameters_header *phdr = NULL; struct visor_controlvm_parameters_header *phdr = NULL;
phdr = (struct visor_controlvm_parameters_header *)(ctx->data); phdr = &ctx->data;
if (phdr->name_offset + phdr->name_length > ctx->param_bytes) if (phdr->name_offset + phdr->name_length > ctx->param_bytes)
return NULL; return NULL;
ctx->curr = ctx->data + phdr->name_offset; ctx->curr = (char *)&phdr + phdr->name_offset;
ctx->bytes_remaining = phdr->name_length; ctx->bytes_remaining = phdr->name_length;
return parser_string_get(ctx); return parser_string_get(ctx);
} }
...@@ -1455,17 +1452,15 @@ void visorbus_device_changestate_response(struct visor_device *dev_info, ...@@ -1455,17 +1452,15 @@ void visorbus_device_changestate_response(struct visor_device *dev_info,
static struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, static struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes,
bool *retry) bool *retry)
{ {
int allocbytes = sizeof(struct parser_context) + bytes; int allocbytes;
struct parser_context *ctx; struct parser_context *ctx;
void *mapping; void *mapping;
*retry = false; *retry = false;
/* /* alloc an extra byte to ensure payload is \0 terminated */
* alloc an 0 extra byte to ensure payload is allocbytes = bytes + 1 + (sizeof(struct parser_context) -
* '\0'-terminated sizeof(struct visor_controlvm_parameters_header));
*/
allocbytes++;
if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) if ((chipset_dev->controlvm_payload_bytes_buffered + bytes)
> MAX_CONTROLVM_PAYLOAD_BYTES) { > MAX_CONTROLVM_PAYLOAD_BYTES) {
*retry = true; *retry = true;
...@@ -1482,7 +1477,7 @@ static struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, ...@@ -1482,7 +1477,7 @@ static struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes,
mapping = memremap(addr, bytes, MEMREMAP_WB); mapping = memremap(addr, bytes, MEMREMAP_WB);
if (!mapping) if (!mapping)
goto err_finish_ctx; goto err_finish_ctx;
memcpy(ctx->data, mapping, bytes); memcpy(&ctx->data, mapping, bytes);
memunmap(mapping); memunmap(mapping);
ctx->byte_stream = true; ctx->byte_stream = true;
chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes; chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment