/* Return value: NULL: when can't find a table matching the key ERR_PTR(error): error value virt table address: when a matched table is found  */
struct sfi_table_header* __ref sfi_check_table(u64 pa, struct sfi_table_key *key)
/* Return value: NULL: when can't find a table matching the key ERR_PTR(error): error value virt table address: when a matched table is found  */
struct sfi_table_header* __ref sfi_check_table(u64 pa, struct sfi_table_key *key)
{
	struct sfi_table_header *th;
	void *ret = NULL;
	th = sfi_map_table(pa);
	if (!th)
		return ERR_PTR(-ENOMEM);
	if (!key->sig) {
		sfi_print_table_header(pa, th);
		if (sfi_verify_table(th))
			ret = ERR_PTR(-EINVAL);
	} else {
		if (!sfi_table_check_key(th, key))
			return th;
	}
	sfi_unmap_table(th);
	return ret;
}