xen: guestcopy: Provide an helper to safely copy string from guest
authorJulien Grall <julien.grall@linaro.org>
Tue, 28 Apr 2015 14:32:29 +0000 (15:32 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 8 May 2015 14:41:58 +0000 (15:41 +0100)
commit6ea9f0481eecc5ac4810be200e5f69d26c3af374
treed56216c728672ed0165b323cfdacd1de5d5ce698
parentb49a7517bbbb7e46b52c5dca2d3f4d48be696c4a
xen: guestcopy: Provide an helper to safely copy string from guest

Flask code already provides a helper to copy a string from guest. In a later
patch, the new DT hypercalls will need a similar function.

To avoid code duplication, copy the flask helper (flask_copying_string) to
common code:
    - Rename into safe_copy_string_from_guest
    - Add comment to explain the extra +1
    - Return the buffer directly and use the macros provided by
    xen/err.h to return an error code if necessary.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
xen/common/Makefile
xen/common/guestcopy.c [new file with mode: 0644]
xen/include/xen/guest_access.h
xen/xsm/flask/flask_op.c