diff options
author | wanghaibin <wanghaibin.wang@huawei.com> | 2017-10-26 11:23:03 -0400 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2017-10-28 22:25:06 -0400 |
commit | b92382620e33c9f1bcbcd7c169262b9bf0525871 (patch) | |
tree | 348fe223141e12c8878019e002b47f80dc6b84e5 | |
parent | f9b269f3098121b5d54aaf822e0898c8ed1d3fec (diff) |
KVM: arm/arm64: vgic-its: Fix return value for device table restore
If ITT only contains invalid entries, vgic_its_restore_itt
returns 1 and this is considered as an an error in
vgic_its_restore_dte.
Also in case the device table only contains invalid entries,
the table restore fails and this is not correct.
This patch fixes those 2 issues:
- vgic_its_restore_itt now returns <= 0 values. If all
ITEs are invalid, this is considered as successful.
- vgic_its_restore_device_tables also returns <= 0 values.
We also simplify the returned value computation in
handle_l1_dte.
Signed-off-by: wanghaibin <wanghaibin.wang@huawei.com>
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
-rw-r--r-- | virt/kvm/arm/vgic/vgic-its.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 77652885a7c1..76685f4c6261 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c | |||
@@ -1936,6 +1936,14 @@ static int vgic_its_save_itt(struct vgic_its *its, struct its_device *device) | |||
1936 | return 0; | 1936 | return 0; |
1937 | } | 1937 | } |
1938 | 1938 | ||
1939 | /** | ||
1940 | * vgic_its_restore_itt - restore the ITT of a device | ||
1941 | * | ||
1942 | * @its: its handle | ||
1943 | * @dev: device handle | ||
1944 | * | ||
1945 | * Return 0 on success, < 0 on error | ||
1946 | */ | ||
1939 | static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) | 1947 | static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) |
1940 | { | 1948 | { |
1941 | const struct vgic_its_abi *abi = vgic_its_get_abi(its); | 1949 | const struct vgic_its_abi *abi = vgic_its_get_abi(its); |
@@ -1947,6 +1955,10 @@ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) | |||
1947 | ret = scan_its_table(its, base, max_size, ite_esz, 0, | 1955 | ret = scan_its_table(its, base, max_size, ite_esz, 0, |
1948 | vgic_its_restore_ite, dev); | 1956 | vgic_its_restore_ite, dev); |
1949 | 1957 | ||
1958 | /* scan_its_table returns +1 if all ITEs are invalid */ | ||
1959 | if (ret > 0) | ||
1960 | ret = 0; | ||
1961 | |||
1950 | return ret; | 1962 | return ret; |
1951 | } | 1963 | } |
1952 | 1964 | ||
@@ -2103,10 +2115,7 @@ static int handle_l1_dte(struct vgic_its *its, u32 id, void *addr, | |||
2103 | ret = scan_its_table(its, gpa, SZ_64K, dte_esz, | 2115 | ret = scan_its_table(its, gpa, SZ_64K, dte_esz, |
2104 | l2_start_id, vgic_its_restore_dte, NULL); | 2116 | l2_start_id, vgic_its_restore_dte, NULL); |
2105 | 2117 | ||
2106 | if (ret <= 0) | 2118 | return ret; |
2107 | return ret; | ||
2108 | |||
2109 | return 1; | ||
2110 | } | 2119 | } |
2111 | 2120 | ||
2112 | /** | 2121 | /** |
@@ -2136,8 +2145,9 @@ static int vgic_its_restore_device_tables(struct vgic_its *its) | |||
2136 | vgic_its_restore_dte, NULL); | 2145 | vgic_its_restore_dte, NULL); |
2137 | } | 2146 | } |
2138 | 2147 | ||
2148 | /* scan_its_table returns +1 if all entries are invalid */ | ||
2139 | if (ret > 0) | 2149 | if (ret > 0) |
2140 | ret = -EINVAL; | 2150 | ret = 0; |
2141 | 2151 | ||
2142 | return ret; | 2152 | return ret; |
2143 | } | 2153 | } |